W
W
wawa2018-06-13 02:52:13
Django
wawa, 2018-06-13 02:52:13

Why and how does Django affect time.localtime?

I noticed that Django (apparently through the TIME_ZONE setting) affects the work of the built-in time.localtime function.
I thought that this function relies on the OS time zone, but dzhanga somehow influences it. How does this happen? and why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wawa, 2018-06-14
@wawa

Yes, django affects time.localtime() via os.environ['TZ'] and time.tzset() if USE_TZ=True is set. And unlike my assumption that django settings only affect django itself (django.utils.timezone.local()), it turned out that in the end ALL aware datetime.datetime created in such an environment will use the TIMEZONE slipped by django. Oh, those global variables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question