I've installed the postgresql for my django project. Earlier when i installed it and run makemigrations,it worked fine, but due to some reasons i had to uninstall postgresql and removed its files and re-installed the postgresql,when i run it now, it was showing me this insane error.
Settings File:
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '*****',
'USER': '*****',
'PASSWORD': '',
Error:
File "/Users/Devadanam/Desktop/trackingsys/lib/python2.7/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/Devadanam/Desktop/trackingsys/lib/python2.7/site-packages/django/db/utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/Devadanam/Desktop/trackingsys/lib/python2.7/site-packages/django/db/utils.py", line 134, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgresql' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'sqlite3'
Error was: No module named postgresql.base
It looks like you haven't installed psycopg2
pip install psycopg2
Another possible reason is
Changed in Django 1.9:
The django.db.backends.postgresql backend is named django.db.backends.postgresql_psycopg2 in older releases. For backwards compatibility, the old name still works in newer versions.
https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-DATABASE-ENGINE
So you should change to use django.db.backends.postgresql
The problem is i have deleted the postgresql files in the my virtulenv's lib/python/../django/db.. I created a new virtualenv and all postgres files were back. Excuse me for that!