0

I am rendering a queryset to a template and csv.

models.One2OneInfoLog.objects.filter(one_2_one_info=pk).values_list(Lower('name'), 'location', 'created').order_by('created')

in the template view I get a created value: 16-06-2021, 10:58 in csv file I get: 2021-06-16 08:58:27.780570+00:00

It seems its writing the timestamp in the csv file by deducting 2 hours. Is their some way to correct it? And can I change the formatting to match the template view.

1
  • 1
    This might be due to timezone diferences. The datetime is shown in UTC time, whereas you entered it probably in CET which is 2 hours ahead during the summer, and 1 hour ahead in the winter. Commented Jun 16, 2021 at 15:49

1 Answer 1

1

This seems to be a time zone issue. The data storage saves times in UTC time. More information on setting up time zones can be found in the docs for Django here

Time zone support is disabled by default. To enable it, set USE_TZ = True in your settings file. By default, time zone support uses pytz, which is installed when you install Django; Django also supports the use of other time zone implementations like zoneinfo by passing tzinfo objects directly to functions in django.utils.timezone.

Sign up to request clarification or add additional context in comments.

1 Comment

It is still outputting UTC time to the CVS. I would like it to output CET as it does on my website.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.