django DateTimeField with UTC offset?

前端 未结 1 840
别那么骄傲
别那么骄傲 2021-02-07 05:21

I have a model with a DateTimeField:

deadline = models.DateTimeField(verbose_name=\"Valid unitl\", null=True, blank=True)

Users should be allow

相关标签:
1条回答
  • 2021-02-07 06:01

    When you set USE_TZ = True in your settings, Django stores date and time information in UTC in the database otherwise it will store naive date time (date time without timezone).

    In most cases using Django's time zones support is very convenient because input and output datetime will be automatically translate by Django.

    But if you really need timezone input from your user, you will need to set USE_TZ = False then use DateTimeField which is naive datetime along with CharField to store timezone information in your models.py.

    ref: https://docs.djangoproject.com/en/1.4/topics/i18n/timezones/

    0 讨论(0)
提交回复
热议问题