报错记录: raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you h

这是在github上下载开源的django 网站报错的。

报错内容如下:
raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you have %s.’ % Database.version)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

解决方案:

  1. 尝试下面网址的解决方案:
    https://www.cnblogs.com/olivertian/p/10919550.html
    一、Django数据同步过程中遇到的问题:

1、raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you have %s.’ % Database.version)

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

解决办法:C:\Python37\Lib\site-packages\django\db\backends\mysql(python安装目录)打开base.py,注释掉以下内容:

if version < (1, 3, 13):

raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you have %s.’ % Database.version)
我的不是一样的,我的在D:\Anaconda3\Lib\site-packages\django\db\backends\mysql base.py
if version < (1, 4, 0):
raise ImproperlyConfigured(‘mysqlclient 1.4.0 or newer is required; you have %s.’ % Database.version)

2、File “C:\Python37\lib\site-packages\django\db\backends\mysql\operations.py”, line 146, in last_executed_query

query = query.decode(errors=‘replace’)

AttributeError: ‘str’ object has no attribute ‘decode’

解决办法:打开此文件把146行的decode修改为encode

1.这个跟我的有点不一样,我用的是anaconda3 vs code 找到的django没有那个文件。

2.我的方件位置好像在这里: D:\Anaconda3\Lib\site-packages\django\db\backends\mysql
这个位置找到base.py 并注了相关内容。

3.然找operation.py那个位置没有找到。我直接运行了一下报错
是File “D:\Anaconda3\lib\site-packages\django\db\models\fields\related.py”, line 801, in init
raise TypeError(‘on_delete must be callable.’)

解决方案:
menu = models.ForeignKey(to=‘Menu’, on_delete=models.CASCADE, verbose_name=‘所属菜单’,

把所有models.py里报错的 on_delete="xx"改成上面那样了。

4.还有报错的是:SystemCheckError: System check identified some issues:
ERRORS:
?: (corsheaders.E013) Origin ‘*’ in CORS_ORIGIN_WHITELIST is missing scheme or netloc
HINT: Add a scheme (e.g. https://) or netloc (e.g. example.com).

解决方案:
为什么会将字符串拆分成字符进行检测?django会对‘http://127.0.0.1:*’进行迭代处理? 直接配置成一个列表试试,改成下面:

1
2
3
CORS_ORIGIN_WHITELIST = (
[‘http://127.0.0.1:*’]
)
这个解决了。
问题:
django.db.migrations.exceptions.NodeNotFoundError: Migration generic.0001_initial dependencies reference nonexistent parent node (‘rbac’, ‘0001_initial’)

最后的解决方案还是按这个一下解决了

1.pip uninstall django.
2./Lib/site-packages, deleted django folder.
3.Deleted all *.pyc files in my project.
4.Deleted all pycache folders in my project.
5.Cleared all migrations folders in my project (keep init.py).
6.pip install django==x.x.x.
7.python manage.py migrate.

搞定了。哈哈。。。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值