Django datetime field fractional support -
i have django 1.9.5 installed mariadb 10.1.13 (also tested mysql 5.6.30) (which updated mysql 5.5) , trying fractional seconds support in date time field.
i have created test model try , working, here definition
class history(models.model): date = models.datetimefield(null=true)
then in shell have run following
history(date=datetime.now()).save()
and when query it
type(history.objects.get(id=1).date)
i
<type 'nonetype'>
even though entry appears in database.
i can use field in query
history.objects.all().order_by('date')
i know works because inspecting data shows order has changed
but need able return date can compare another.
i using mysql 5.5 without fractional support there records in database have same datetime field , order_by didnt work, using order_by id , worked whilst records entered chronologically, isnt case need fractional support.
any ideas?
for sort of situation might better store date , time unix timestamp in database. there millisecond accuracy. can convert python datetime objects @ anytime fromtimestamp.
last not least, can convert unix timestamps javascript date times in user's own timezone. process that's far more complex django or other server side tech.
Comments
Post a Comment