django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlc...

使用Django2.0进行开发是出现如上错误,具体如下:

Traceback (most recent call last):
  ...
    import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'

The above exception was the direct cause of the following exception:
...
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?

解决方案:
init.py文件里添加两行代码:

import pymysql

pymysql.install_as_MySQLdb()

你可能感兴趣的:(Error)