Open sveetch opened 1 year ago
A change for this timezone problem has been made in a test for Category serializer after adding a new datetime field to the model:
It seems only Article publish_datetime serializer field is missing the timezone. There is also Article publish_time but i'm not sure it would need the timezone and maybe it is not useful to have the divided publish date and time in payload ?
Describe the bug DjangoRestFramework apply current timezone to the datetime values in serializer fields. Concretely it applies the timezone defined in
settings.TIMEZONE
to datetimes in serializer payload.Environment Describe your environment:
To Reproduce
However from serializers tests it seems that
ArticleSerializer.publish_datetime()
has no timezone applied from output serializer, this is because we use aSerializerMethodField
for it so we don't have theserializers.DateTimeField
behavior.Expected behavior All date should behave the same. We can apply the timezone in
ArticleSerializer.publish_datetime()
but it needs to copy the DRF one, that seem to be conditionned tosettings.USE_TZ
value.Additional context This should be a concern only in API, but view/templatetag code have to be inspected to check if they use something like
isoformat()
formatting which would transform date object in string, that Django would not be able to apply current timezone.