我有一个在数据库中的现有模型。我想用hstore字段来增强它。我安装hstore Postgres的扩展,Django的hstore应用,在Django项目改变了适当的设置:如何在添加hstore字段后创建迁移? (django-hstore与南)
SOUTH_DATABASE_ADAPTERS = {'default': 'south.db.postgresql_psycopg2'}
DATABASES = {
'default': {
'ENGINE': 'django_hstore.postgresql_psycopg2',
...
我检查了Django应用程序的工作原理与新设置 - 它。所以我添加了新的字段到其中一个模型:
data = hstore.DictionaryField(db_index=True)
下一步:数据库迁移。在这里我迷路了。当试图为新字段创建迁移时,我得到:
The field 'Project.data' 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
我该怎么做?我错过了什么?在任何django-hstore相关文章中,我没有找到任何对默认值(或null = True)的引用。
呀,我试着用{}最初,这申请移民时破产。恐怕hstore.DictionaryField是一个完全不同的野兽。 – Mike 2013-04-09 18:41:28
问题可能是索引标志,我认为数据库将字典作为索引处理很复杂。 – PepperoniPizza 2013-04-09 19:55:46
实际上起初我没有尝试过,原来它是hstore DictionaryField的默认设置。 – Mike 2013-04-09 20:12:06