1๐
โ
I think you are seeing this issue because Django creates a date with microseconds when you do the post request. However, when you save to the database, the microseconds are truncated, so you get a different result when you do the get request later. Support was added for microseconds in DateTime fields in MySQL in Django 1.8.
You can define the DateTimeField
explicitly, and specify the date format you require. See this page for an explanation of date formats.
class HadithTagSerializer(serializers.ModelSerializer):
added_on = DateTimeField(format='%Y-%m-%dT%H:%M:%SZ')
updated_on = DateTimeField(format='%Y-%m-%dT%H:%M:%SZ')
class Meta:
model = HadithTag
fields = ['name', 'added_on', 'updated_on']
๐คAlasdair
Source:stackexchange.com