Is current time zone detected by default if `USE_TZ=True` in Django?

190 Views Asked by At

It is mentioned in docs that the current time zone should be activated.

You should set the current time zone to the end user’s actual time zone with activate(). Otherwise, the default time zone is used

However, I see that the values are parsed in my local timezone in the forms correctly without activating it from my side, and TIME_ZONE is UTC which is different from my local timezone.

1

There are 1 best solutions below

1
Kevin Christopher Henry On

No, the user's current time zone is not detected automatically, as discussed here:

There’s no equivalent of the Accept-Language HTTP header that Django could use to determine the user’s time zone automatically.

The fact that time values are parsed according to your local timezone is not correct, since the end user is not necessarily in your time zone. That's why you need to figure out what time zone they're in and use activate().