47

I have worked with python for a while, but never django. I am taking over a project that a different employee made before leaving our company. I am wondering if there is a difference between the option postgresql and postgresql_psycopg2 as a database driver for django.

In some articles and the docs about how to set up a django project I have seen just postgresql and in others I have seen the postgresql_psycopg2. I couldn't find anything in the docs (here or here) that mentioned psycopg2, so is this just the old way of writing the option?

Is one just an alias for the other or are they actually different enignes? I also couldn't find any other SO questions on this.

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',# here I also saw postgres_psycopg2
    'NAME': 'premqcsite',
    'USER': 'django_user',
    'PASSWORD': 'Encepta_123',
    'HOST': 'localhost',
    'PORT': '5432',
}}

1 Answer 1

65

It's the same. django.db.backends.postgresql_psycopg2 used in django <1.8 and it was renamed in django 1.9 to django.db.backends.postgresql. From docs:

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.

2
  • 3
    Is it still required to install pycopg_2 with pip or is it now included in Django?
    – Advena
    Mar 3, 2020 at 15:36
  • 7
    @Tanckom I also had the same question and found out it's not included. You have to install it before running migrate command Mar 7, 2020 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.