django使用mysql报错,错误如下:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
解决方法:
首先安装mysql包
pip install pymysql
然后在你的app目录的__init__.py文件中加入这句:
import pymysql pymysql.install_as_MySQLdb()
成功启动,输出:
/usr/local/bin/python3.7 /Users/panjing/dev/oa/manage.py runserver 8000 Performing system checks... System check identified no issues (0 silenced). You have 14 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. August 30, 2018 - 03:22:40 Django version 2.0.7, using settings 'oa.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.