django.db.utils.IntegrityError:(1215, canot add foreign key constraint)
2016-03-16 22:37
459 查看
django.db.utils.IntegrityError:(1215, canot add foreign key constraint)
执行python manage.py migrate创建数据库表时出现的问题,后来看Django document migrations,找到原因。我在models.py中定义了一个User表,此表继承django.contrib.auth中的User表。python manage.py migrate在建表的过程中先创建了我在models.py 中创建的User表,这样问题就来了,找不到父类的表,就出现can not add foreign key
constraint 这个错误。先保证django.contrib.auth中的user表建立,然后在创建自己定义的user表就可以了
执行python manage.py migrate创建数据库表时出现的问题,后来看Django document migrations,找到原因。我在models.py中定义了一个User表,此表继承django.contrib.auth中的User表。python manage.py migrate在建表的过程中先创建了我在models.py 中创建的User表,这样问题就来了,找不到父类的表,就出现can not add foreign key
constraint 这个错误。先保证django.contrib.auth中的user表建立,然后在创建自己定义的user表就可以了
相关文章推荐
- main函数的两个参数
- URAL1017Staircases DP
- maven install时报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
- 从WinMain开始
- Pairs Forming LCM(素因子分解)
- clang: error: linker command failed with exit code 1 (use -v to see invocation)解决方法
- maven install Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war
- 在fairland的生活
- Raid及LVM原理
- lightOJ 1236 Pairs Forming LCM(算术基本定理)
- async和await
- SharePoint Claim base authentication EnsureUser 不带claim(i:0#.w|)user Failed
- Linux waitpid
- 11. Container With Most Water
- 解析main函数的命令行参数
- String painter
- ArcGIS调用DataInteroperabilityTools导出数据
- 加了FLAG_ACTIVITY_SINGLE_TOP后,不能再多次创建MainActivity
- LightOJ 1138 - Trailing Zeroes (III)(二分&阶乘末尾0的个数)
- DELL R730安装xenserver 6.2,raid卡驱动问题