U
U
Untiwe2021-01-09 15:57:01
Django
Untiwe, 2021-01-09 15:57:01

Why is django storing the wrong time?

System settings

LANGUAGE_CODE = 'ru'
TIME_ZONE = 'GMT'
USE_I18N = True
USE_L10N = True
USE_TZ = True

Model field
date_create = models.DateTimeField(auto_now_add = True, help_text='Дата создания')

In this case, all models in the database are recorded with a difference of -3 hours (recorded at 15:00 in the database at 12:00). But the standard messages in the console have the correct time (the console itself writes the time of the message)
instead of auto_now_add, setting default = "datetime.now" also does not help.
Tell me how to fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-01-09
@Untiwe

And figure it out first with naive and aware datetime https://docs.djangoproject.com/en/3.1/topics/i18n/... well, the FAQ for one https://docs.djangoproject.com/en/3.1/topics /i18n/...
PS well, it's still customary to leave UTC, and not enter GMT, otherwise confusion and possible errors (I'm not sure here, I haven't checked)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question