i have both psycopg2 and psycopg3, the latter is installed by a dependency and i would still like to use psycopg2 for django. Django picks up psycopg2 even after setting engine
. What i’m i doing wrongly?
"default": dj_database_url.config(
engine="django.db.backends.postgresql_psycopg2",
default=env("DATABASE_URL"),
),
there is a mention of the module removal here. but yet this part of the documentation still supports it still
Welcome @paulwvnjohi !
This is not a valid engine name. The engine name is as described in the docs - “django.db.backends.postgresql”. This is actually a reference to a python module within Django, and not a reference to the database driver module itself.
The django.db.backends.postgresql.base
and django.db.backends.postgresql.psycopg_any
modules will try to load psycopg
first, and if it fails, will then try to load psycopg2
.
If you want to use psycopg2 you need to either uninstall psycopg or clone the postgresql engine and create your own where it only uses psycopg2.