Question

I just followed instructions on django website https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-date-based/ and TodayArchiveView was showing the date for the next day.

my setting TIME_ZONE = 'UTC' and I changed it to TIME_ZONE = 'America/Los_Angeles' and TodayArchiveView worked but is this the right way? what if a user is in europe will he get the right time zone?

Was it helpful?

Solution

Your user will not see right time zone, because Django doesn't have a way to get user timezone as far as I know and it was also stated, here see accepted answer. You have three choices to get this right:

  1. Get user timezone with some javascript, take a look at this answer
  2. Get user timezone with some geolocation method, like django-easy-timezones
  3. Ask user for his timezone and save it in his profile, then you can activate user timezone in view
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top