我正在为启用时区支持的 Django 1.4.3 项目使用 South 0.7.6 创建模式迁移。
架构迁移包括在一个表上添加DateTimeField
(with )。auto_now=True
创建迁移时,South 提示我:
The field 'MyTable.my_field' does not have a default specified, yet is NOT NULL.
Since you are adding this field, you MUST specify a default
value to use for existing rows. Would you like to:
1. Quit now, and add a default to the field in models.py
2. Specify a one-off value to use for existing columns now
如果我不关心现有行的这个值(我只希望迁移成功而没有警告),那么在这里给出的正确一次性值是什么?
到目前为止,我使用了datetime.datetime.utcnow()
. 但是,在应用迁移时我得到以下信息:
C:\Python27\lib\site-packages\django\db\models\fields\__init__.py:808:
RuntimeWarning: DateTimeField received a naive datetime (2013-01-16 00:00:00)
while time zone support is active.
South 似乎没有导入 pytz 或 Django 辅助类,那么我如何在这里给出一个时区感知的默认值呢?