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
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章