作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 South使用 Django 进行数据库迁移。
在我的 models.py
我改变了一个领域
class User(models.Model):
group = models.ForeignKey(Group)
class User(models.Model):
group = models.ForeignKey(Group, null = True, blank = True)
group
字段为
User
可选的。
(doors)hobbes3@hobbes3:~/Sites/mysite$ python manage.py schemamigration doors --auto
? The field 'User.group' does not have a default specified, yet is NOT NULL.
? Since you are making this field nullable, 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
? 3. Disable the backwards migration by raising an exception.
? Please select a choice:
null = True
指定了默认值 NULL和
blank = True
?
doors_user
mysite=# \d doors_user
Table "public.doors_user"
Column | Type | Modifiers
-------------+--------------------------+---------------------------------------------------------
id | integer | not null default nextval('doors_user_id_seq'::regclass)
group_id | integer | not null
user_type | character varying(1) | not null default 't'::character varying
comment | text | not null
email | character varying(75) | not null
password | character varying(135) | not null
first_name | character varying(135) | not null
last_name | character varying(135) | not null
phone | character varying(135) | not null
status | character varying(1) | not null default 'p'::character varying
location_id | integer |
t_created | timestamp with time zone | not null
t_modified | timestamp with time zone | not null
Indexes:
"doors_user_pkey" PRIMARY KEY, btree (id)
"doors_user_group_id" btree (group_id)
"doors_user_location_id" btree (location_id)
Foreign-key constraints:
"group_id_refs_id_2fde5e861cc0e5fe" FOREIGN KEY (group_id) REFERENCES doors_group(id) DEFERRABLE INITIALLY DEFERRED
"location_id_refs_id_13c85dcc5cba5e23" FOREIGN KEY (location_id) REFERENCES doors_location(id) DEFERRABLE INITIALLY DEFERRED
Referenced by:
TABLE "doors_property" CONSTRAINT "owner_id_refs_id_7a3a10af3eba8739" FOREIGN KEY (owner_id) REFERENCES doors_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "doors_order" CONSTRAINT "user_action_id_refs_id_79506d7c5228f713" FOREIGN KEY (user_action_id) REFERENCES doors_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "doors_order" CONSTRAINT "user_created_id_refs_id_79506d7c5228f713" FOREIGN KEY (user_created_id) REFERENCES doors_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "doors_log" CONSTRAINT "user_id_refs_id_3ce582a126688737" FOREIGN KEY (user_id) REFERENCES doors_user(id) DEFERRABLE INITIALLY DEFERRED
TABLE "doors_ordercomment" CONSTRAINT "user_id_refs_id_6d10d6e79572e14d" FOREIGN KEY (user_id) REFERENCES doors_user(id) DEFERRABLE INITIALLY DEFERRED
SELECT
陈述
mysite=# select * from doors_user;
id | group_id | user_type | comment | email | password | first_name | last_name | phone | status | location_id | t_created | t_modified
----+----------+-----------+---------+------------------+----------+------------+-----------+-------+--------+-------------+------------------------------+-------------------------------
1 | 1 | w | | blah12@gmail.com | ads | Michael | Anderson | | a | | 2012-03-04 06:44:44.97263-05 | 2012-03-04 06:44:44.972661-05
(1 row)
最佳答案
我认为...... South 正在考虑是否您想将迁移回滚到
class User(models.Model):
group = models.ForeignKey(Group)
关于Django 南迁移不适用于 null = True 和空白 = True,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9557578/
我是一名优秀的程序员,十分优秀!