6

I am trying to migrate an app from Django 1.8 and Python 2 to Python 3.6 and Django 3.0.

Whenever I am adding django.db.backends.postgresql_psycopg2, and installing it via pip3 I am getting this error:

_psycopg2 module not found.

I looked at the documentation, and I see that in Django 3.0 _psycopg2 is removed. How can I resolve this issue? My previous app is running psycopg 2.6.1.

1

1 Answer 1

13

The correct setting to use in Django 3.0 is 'django.db.backends.postgresql'.

From the Django deprecation timeline:

The django.db.backends.postgresql_psycopg2 module will be removed.

This particular module has actually been deprecated since Django 2.0:

The django.db.backends.postgresql_psycopg2 module is deprecated in favor of django.db.backends.postgresql. It’s been an alias since Django 1.9. This only affects code that imports from the module directly. The DATABASES setting can still use 'django.db.backends.postgresql_psycopg2', though you can simplify that by using the 'django.db.backends.postgresql' name added in Django 1.9.

From the databases docs, it looks like your version of psycopg2 should be supported, as you need 2.5.4 or higher.

Sign up to request clarification or add additional context in comments.

4 Comments

Yeh I did that, And I installed Postgres. but when I run my app I get django.db.utils.OperationalError Could not connect to server on port 5432 . this is first time am creating an app. and I still couldn't run it.
That sounds like a completely distinct problem from the question you posted. You should include all information in your question so that it's clear what your actual problem is. Have you looked at this post with respect to not being able to connect to Postgres from Django?
I checked that one, and it didn't help. I am trying the command they given service postgresql status it keeps giving me Postgres.service no found
I'm really not sure how to solve that issue, but I'm sure this has been asked before, such as here. See what else you can try, and if that doesn't resolve it, post a new question with the information you gave me here, ideally a full traceback of the error you're getting and what you've tried so far, and hopefully someone will be able to solve your problem. I did my best to answer your question here based on the information you provided, but it seems you have issues with Postgres itself, which has nothing to do with Django.

Your Answer

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