I am trying to switch my Django database from SQLite3 to PostgreSQl, so I follow many tutorials to install and setup Postgres with Django project.
I did the following: pip install psycopg2
, pip install psycopg2-binary
and I modified the settings.py like that:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': BASE_DIR / 'db.postgresql',
'USER': 'muusername',
'PASSWORD': 'mypassword',
'HOST': '127.0.0.1',
'PORT': '5432'
}
}
Finally I maked my database, by running the command python manage.py makemigrations
.
However, I got this error:
django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgresql' isn't an available database backend or couldn't be imported. Check the above exception. To use one of the built-in backends, use 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'sqlite3'
Please note that I am also seccesufully install the pgAdmin in my OS which is Windows 10 in a first step.
I know that the problem is related by configuration of Postgres in my django project, but I don’t know how to fix it, also I checked my djnago version which is the latest one, also, all needed packages are installed in my venv.
3
Answers
I solve this problem by just upgrade the django, as you can see here in the exception:
Django ask the user to use mysql, oracle or sqlite3, but not the case of postgresql. So this exception will be fixed when the user upgrade the django version.
I hope this answer can be helpful for someone another.
You cannot add like this in postgres:
Just add
db_name
inNAME
:Make sure you have actually downloaded the PostgreSQL installer itself and installed it.