【Django】django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4.0 or newer is required
在setting.py的__init__.py里
问题:
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.4.0 or newer is required
解决方案:
import pymysql
pymysql.version_info = (1, 4, 13, "final", 0)
pymysql.install_as_MySQLdb() # 使用pymysql代替mysqldb连接数据库
问题:
WARNINGS:
blog.Category: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BlogConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.B
blog.Post: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
igAutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BlogConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.B
igAutoField'.
解决方案:
settings.py 添加
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

浙公网安备 33010602011771号