【发布时间】:2021-02-08 16:54:36
【问题描述】:
我在我的 django 博客项目上运行 manage.py migrate 并得到这个:
(joelgoldstick.com) jcg@jcg-hp:~/code/p3/joelgoldstick.com/blog$ python manage.py migrate
.
.
.
django.db.utils.OperationalError: table "django_content_type" already exists
During handling of the above exception, another exception occurred:
.
.
.
raise IntegrityError(
django.db.utils.IntegrityError: The row in table 'blog_app_entry_categories' with primary key '8' has an invalid foreign key: blog_app_entry_categories.category_id contains a value '3' that does not have a corresponding value in blog_category.id.
但表 blog_app_category 包含 id = 3 的行
这是表格:
sqlite> select id from blog_app_entry;
id
2
3
4
5
6
7
8
9
11
12
14
15
16
sqlite> select * from blog_app_category;
id|title|slug|description
1|Programming for fun|programming-fun|just a sample category.
2|Django|django|Anything related to django
3|python|python|general python
4|tools|tools|various tools
5|Patty|patty|This is patty's stuff
6|Misc|misc|Things that don't fit in other categories
7|Vim|vim|About the Vim Editor
8|random|random|random category for testing
9|Deployment|deployment|deployment articles
10|git|git|git tips
sqlite> select * from blog_app_entry_categories;
id|entry_id|category_id
8|4|3
22|3|2
23|3|3
25|6|2
26|6|4
30|11|2
31|11|3
33|7|4
35|8|2
36|8|4
38|9|1
39|9|3
41|14|2
42|15|2
45|5|4
47|2|2
48|12|6
49|16|6
【问题讨论】:
标签: python-3.x django sqlite