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