python manage.py makemigrations 报错

python manage.py makemigrations 报错
运行 python manage.py makemigrations 出现错误如下:
##错误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.

solution:
.\Lib\site-packages\django\db\backends\mysql.路径下找到base.py, 修改如下内容:
#if version < (1, 3, 13): ==> if version < (1, 3, 3):

##错误2:

query = query.decode(errors=‘replace’)
AttributeError: ‘str’ object has no attribute ‘decode’
solution:

去到python的安装路径: \Lib\site-packages\django\db\backends\mysql
open ./site-packages/django/db/backends/mysql/operations.py
将decode改为encode

##错误3:

File “C:\Python\Python37\lib\site-packages\django\template\backends\django.py”, line 125, in get_package_libraries
"trying to load ‘%s’: %s" % (entry[1], e)
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load ‘django.contrib.admin.templatetags.admin_static’: cannot import name ‘RemovedInDjango30Warning’ from ‘django.utils.deprecation’ (.\lib\site-packages\django\utils\deprecation.py)

solution:
we need to uninstalled Django-3.0, reinstalled django-2.2.1

********===================************
Migrations for ‘myAPP’:
myAPP\migrations\0001_initial.py

  • Create model Grades
  • Create model Students

Ubuntu
在这里插入图片描述

发布了61 篇原创文章 · 获赞 21 · 访问量 9092

猜你喜欢

转载自blog.csdn.net/xbean1028/article/details/104485999