django错误集合

不小心删除了migrations然后生成不了迁移文件了

执行python manage.py makemigrations --empty 你的应用名
执行python manage.py makemigrations

然后迁移文件就文件夹出来

django.db.utils.OperationalError: (2013, ‘Lost connection to MySQL server during query‘)

解决办法:看看MySQL服务是否启动

在Django2.2启动时出现错误:LookupError: No installed app with label ‘admin’

解决办法:
1.配置好数据库
2. pip install mysqlclient
3.如果以上还是没有解决去下载 pip install django==2.18

Forbidden (403)CSRF verification failed. Request aborted.

原因是因为csrf需要在from表单提交的时候加上{% csrf_token %}
csrf是跨站请求伪造,是cookie引起的,cookie是用来实现状态保持的,它存在客户端是较为不安全的,csrf是防止恶意网站利用客户端的cookie来发送请求的
在这里插入图片描述

django.template.exceptions.TemplateSyntaxError: ‘ifequal’ takes two arguments

在这里插入图片描述

django.db.utils.IntegrityError: (1215, ‘Unknown error 1215’)

解决办法:
需要在settings的数据库配置需要添加
在这里插入图片描述

'OPTIONS': {

                    "init_command": "SET foreign_key_checks = 0;",

                }

django.db.migrations.exceptions.InconsistentMigrationHistory

我出现这个问题的原因是继承并扩展了 模型类 的 AbstractUser 类,进行迁移的时候,由于项目已经创建了 user 相关的表,该表与我的表功能一致,故发生了冲突。
解决办法:
1.删除相关的表
2.删除 django_migrations 中相关的记录

Runt: imeError: Model class apps. users. models. UserProfile doesn’ t declare an explicit app_ label and isn’t in an application in INSTALLED_ APPS.

出现这个问题的解决办法:
django版本2.2.2
1.看看settings是否导app,最好是这种app配置
在这里插入图片描述
2.再去看看app下面的apps是否是这样的
在这里插入图片描述
我的就是因为没有apps报的错

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值