1

好的,所以我有一个应用程序,我想将其转换为南(如果这是正确的术语)。我想这样做是因为我有一个模型并且我做到了

python manage.py syncdb

然后我对模型进行了更改,然后它没有让我同步数据库。在做了一些改变之后,我发现使用南是解决方案。所以我把南方放在我安装的应用程序中然后我做了

python manage.py syncdb

并安装在南方。然后,按照 www.djangopro.com/2011/01/django-database-migration-tool-south-explained/ 上的说明,我做了

manage.py convert_to_south myapp 

为第 1 代创建迁移文件,并创建迁移历史条目,该条目有效。接下来,我做了

manage.py schemamigration myapp --auto

它说

 ? The field 'Users.date_of_birth' 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
 ? Please select a choice: 2
 ? Please enter Python code for your one-off default value.
 ? The datetime module is available, so you can do e.g. datetime.date.today()
 >>> 

这是什么意思?难道我做错了什么?我应该为开关默认值设置什么值?

当我查看这个网站时: south.readthedocs.org/en/latest/tutorial/part3.html ,我看到当他们使用 schemamigration --auto 并在名为 southtut 的应用程序上迁移时,它并没有要求一个-在开始时关闭默认值,所以我猜我做错了什么。有任何想法吗?

4

1 回答 1

2

No everything is fine. You have Users.date_of_birth field which does not have default value specified in the model e.g. default=datetime.now(), so that is why it is asking to specify the default value for the migration for older entries.

After step two when it says:

The datetime module is available, so you can do e.g. datetime.date.today()

Just do datetime.date.today() and press enter or choose any default date for the date_of_birth field.

于 2013-09-13T02:33:37.200 回答