django 报错:ValueError: The database backend does not accept 0 as a value for AutoField.
来源:互联网 发布:flask mysql 编辑:程序博客网 时间:2024/05/16 14:55
错误原因:
在创建一个model时,其中一个字段你用了别一个model的做为外键,并且给这个外键设置了一个默认值 ,而这个默认值不适用于键model中自动创建
再找一下报错的脚本:
Applying oiarpt.0004_auto_20170822_1419... OK Applying oiarpt.0005_auto_20170822_1652...Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "D:\python3.6\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
由上面的信息可以看出在执行:Applying oiarpt.0005_auto_20170822_1652…Traceback (most recent call last):时报错的:
打开项目\oia_report\oiarpt\migrations 找到对应的文件可以看到:
field=models.ForeignKey(default=0, on_delete=django.db.models.deletion.CASCADE, to='oiarpt.Product'),
问题就出在这里:
解决方法:
删除0005_auto_20170822_1652.py
然后重新执行:
python manage.py makemigrations
python manage.py migrate
此时就不会报错了
阅读全文
0 0
- django 报错:ValueError: The database backend does not accept 0 as a value for AutoField.
- django migrate raise ValueError('The database backend does not accept 0 as a '
- mysql出现The user specified as a definer ('root'@'%') does not exist报错!
- 关于mysql存储过程报错The user specified as a definer ('oem'@'%') does not exist
- mysql出现The user specified as a definer ('root'@'%') does not exist报错!
- 数据库报错The user specified as a definer ('root'@'%') does not exist 解决方法
- 报错500:The user specified as a definer ('***'@'localhost') does not exist解决方法
- mybatis报错does not contain value for
- mysqldump报错'The user specified as a definer ('root'@'%') does not exist when using LOCK TABLES'
- Python is not installed as a framework. The Mac OS X backend will not be a
- 访问JSP页面报错According to TLD or attribute directive in tag file, attribute value does not accept
- attribute value does not accept any expressions
- Attribute Value Does Not Accept Any Expressions
- mvc3.0 报错Model compatibility cannot be checked because the database does not contain model metadata
- The user specified as a definer (@'''') does not exist
- The user specified as a definer ('root'@'%') does not exist。
- The user specified as a definer ('root'@'%') does not exist
- The user specified as a definer ('root'@'%') does not exist。 .
- IDEA下用springboot搭建web项目
- CSS布局奇淫技巧之–各种居中
- imageload缓存图片
- 兼容所有浏览器的复制到剪切板功能,悬浮层不能复制问题解决
- IntelliJ Idea 常用快捷键列表
- django 报错:ValueError: The database backend does not accept 0 as a value for AutoField.
- JMeter学习-008-JMeter 后置处理器实例之
- 数值的整数次方
- Maven基础-默认中央仓库[settings.xml 配置详解 ]
- MySQL数据库将多条记录的单个字段合并成
- 选择排序和堆排序
- HBase(3)-HBase Shell 中DDL,DML命令演示
- 感知机对偶形式的程序实现
- RBAC基于角色的访问控制模型(权限管理)