Makemigrations和auto_now_add

时间:2016-07-01 16:09:24

标签: django-models

Django 1.9.7

的PostgreSQL

你可以帮我理解我该怎么办? auto_now_addand选项默认是互斥的。

这有点令人困惑。我赞成按1?但只是决定要求一些建议。

模型

creation_date = models.DateField(auto_now_add=True)

回溯

michael@michael:~/workspace/photoarchive$ python manage.py makemigrations
You are trying to add a non-nullable field 'creation_date' to place without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows)
 2) Quit, and let me add a default in models.py

0 个答案:

没有答案