django模型
作者:互联网
一、安装数据库,选择server only 一路下一步
二、连接数据库遇到的问题
- 修改setting文件
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'djangopro1db', 'USER': 'XXX', 'PASSWORD': 'XXX', 'HOST': '127.0.0.1', 'PORT': '3306' } }
- python manage.py makemigrations遇到问题
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
安装django版本django3.0.3,python3.8,Python3中没有MySQLdb这个模块。查了下百度,
pip install pymysql
project.__init__.py加入
import pymysql pymysql.install_as_MySQLdb()
再执行,报错
File "C:\Python38\lib\site-packages\django\db\backends\mysql\base.py", line 37, in <module> 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:\Python38\lib\site-packages\django\db\backends\mysql\base.py,注释以下两行,连接成功。
#if version < (1, 3, 13): # raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
标签:13,1.3,模型,py,mysqlclient,django,ImproperlyConfigured 来源: https://www.cnblogs.com/felix-snail/p/12405667.html