A
A
alk2015-05-16 22:45:20
Django
alk, 2015-05-16 22:45:20

How to make Django automatically determine the time zone?

How can I make Django automatically determine the time zone and display the time corresponding to this zone? If you specify TIME_ZONE = 'Europe/Moscow', then Moscow time will be displayed, even if the person is from Vladivostok...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Vasiliev, 2015-05-17
@Alexey_Kutepov

You can define `new Date.toString()` with Javascript in the browser and somehow pass it to the backend.
For example, in a hidden login field, or with Ajax.

S
sim3x, 2015-05-16
@sim3x

https://docs.djangoproject.com/en/1.8/topics/i18n/...

A
andbiller, 2016-04-27
@andbiller

I recently solved the same problem using a middleware in which I determine the country and time zone using geoip. Everything works automatically! I found this idea here bovs.org/post/166/Casovye-poasa-v-Django-na-prosty...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question