python 关于 django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?

问题出现

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

改成了

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'basename',
        'USER': 'root',
        'PASSWORD': '123456',
        'HOST': '192.168.0.133',
    }
}

解决方法

pip install pymysql

找到init.py修改如下

import pymysql
pymysql.install_as_MySQLdb()

运行程序提示 You have unapplied migrations; your app may not work properly until they are applied. Run ‘python manage.py migrate’ to apply them.

但程序不会报错还是可以访问,但是这个警告看着咋就不爽呢

python manage.py migrate

好啦,大功告成

你可能感兴趣的:(python 关于 django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?)