美文网首页
django.core.exceptions.Improperl

django.core.exceptions.Improperl

作者: 程慕枫 | 来源:发表于2018-07-08 16:24 被阅读0次

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

    Traceback (most recent call last):
      File "/home/san/PycharmProjects/MapleMooc/venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
        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()

    相关文章

      网友评论

          本文标题:django.core.exceptions.Improperl

          本文链接:https://www.haomeiwen.com/subject/sogbjftx.html