I am trying to code without throwing any warnings in my console. So far I have been pretty good at avoiding it until this one case, which seems like a chicken and egg situation to me.
from datetime import datetime as dt
last_contacted = "19/01/2013"
current_tz = timezone.get_current_timezone()
date_time = dt.strptime(last_contacted, get_current_date_input_format(request))
date_time = current_tz.localize(date_time)
The third line is throwing this warning:
RuntimeWarning: DateTimeField received a naive datetime (2013-01-19 00:00:00) while time zone support is active.)
Its kind of odd, since I need to convert the unicode into a datetime first before I can convert the datetime object into an datetime-aware object (with timezone support) in the forth line.
Any suggestions from experts?
Thanks
UPDATE:
def get_current_date_input_format(request):
if request.LANGUAGE_CODE == 'en-gb':
return formats_en_GB.DATE_INPUT_FORMATS[0]
elif request.LANGUAGE_CODE == 'en':
return formats_en.DATE_INPUT_FORMATS[0]
from datetime import datetime as dt
– Houmanget_current_date_input_format
function as well... – Mike Fogelget_current_date_input_format
is doing something special. – Austin Phillips