Yasser Mohsen
Yasser Mohsen

Reputation: 1480

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

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.

Upvotes: 1

Views: 266

Answers (1)

Kevin Christopher Henry
Kevin Christopher Henry

Reputation: 49092

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().

Upvotes: 1

Related Questions