-1

I keep getting the following error when trying to set up MySql database with Django?

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 28, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

Here is my settings.py

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


    'ENGINE': 'django.db.backends.mysql',
    'NAME': 'test_database',
    'USER': 'root',
    'PASSWORD': 'root',
    'HOST': 'localhost',
    'PORT':'8889',



    }
}
copser
  • 2,523
  • 5
  • 38
  • 73
  • 1
    Possible duplicate of [Setting Django up to use MySQL](http://stackoverflow.com/questions/19189813/setting-django-up-to-use-mysql) – copser Feb 22 '17 at 19:39
  • Cool story bro. Was there a *question*? Or you just posting a status report? – spencer7593 Feb 22 '17 at 19:49
  • http://stackoverflow.com/questions/2952187/getting-error-loading-mysqldb-module-no-module-named-mysqldb-have-tried-pre – Manjit Kumar Feb 22 '17 at 20:27

1 Answers1

0

Make sure you have pymysql installed. Then in settings.py add following code just below import os

try:
    import pymysql
    pymysql.install_as_MySQLdb()
except:
    pass
nomad
  • 973
  • 2
  • 9
  • 22