我在models.py from django.db import models
class Blog(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()
created = models.DateTimeField(auto_now_add=True)
我有一個Django(v1.10.6)的項目,有一些機型日期時間字段,例如: created_at = models.DateTimeField(auto_now_add=True)
存儲在PostgreSQL數據庫沒有時區信息: created_at timestamp without time zone NOT NULL
postgresql.conf: timezone = 'UTC
我看到這篇文章Is Django corrupting timezone-aware DateTimeField when saving it to the Database?,但它專門使用pytz和mysql,以及哪些地方我不使用pytz並使用SQLite(因爲它可能會產生影響)。 我有以下型號 class ScheduleItem(models.Model):
work_date =
setings.py:-
USE_TZ = True
TIME_ZONE = 'America/Chicago'
class MyModel(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
# time zone related field
user