I have a Django app with a model that contains a field of type DateTimeField.
I am pulling data from the web in the format of 2008-04-10 11:47:58-05.
I
String format of Django DateTimeField is "%Y-%m-%dT%H:%M:%S.%fZ". Hence, conversion between eachother can be done using strptime() or strptime() using this format.
eg. for string formatted value (2016-10-03T19:00:00.999Z), it can be converted to Django datetime object as :
from datetime import datetime
datetime_str = '2016-10-03T19:00:00.999Z'
datetime_object = datetime.strptime(datetime_str, "%Y-%m-%dT%H:%M:%S.%fZ")