Hi, I stumbled across this yesterday while trying to figure out why some of my tests would sometimes fail when serializing and deserializing datetimes to JSON.
DjangoJSONSerializer only includes the milliseconds in the encoded string if the original datetime has a non-zero microsecond value - this is fine when only dealing with the JSON in Javascript, but in python it requires two different cases when decoding. To make things even more confusing, the milliseconds field can be included even if it's zero: import datetime from django.core.serializers.json import DjangoJSONEncoder e = DjangoJSONEncoder() e.default(datetime.datetime(year=2016, month=1, day=1, hour=1, minute=1, second=1, microsecond=1)) '2016-01-01T01:01:01.000' e.default(datetime.datetime(year=2016, month=1, day=1, hour=1, minute=1, second=1, microsecond=0)) '2016-01-01T01:01:01' This seems like a bug to me (easily fixed by always including the milliseconds), but I wanted to check first if there's a reason for this behaviour, as that code has been there for ages. If this is a bug, I'll be happy to send a PR. Cheers Rob -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c0fcf06a-10ac-4255-950a-462d26595c6e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.