jazzband / dj-database-url

Use Database URLs in your Django Application.
https://pypi.org/project/dj-database-url/
BSD 3-Clause "New" or "Revised" License
1.49k stars 205 forks source link

Django 3.0+ Uses deprecated postgresql_psycopg2 package #131

Closed jkleve closed 2 years ago

jkleve commented 4 years ago

I'm getting this error

Traceback (most recent call last):
  File "/Users/jesse.kleve/src/playgrounds/django/dori/api/venv/lib/python3.7/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
    self.connect()
  File "/Users/jesse.kleve/src/playgrounds/django/dori/api/venv/lib/python3.7/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/Users/jesse.kleve/src/playgrounds/django/dori/api/venv/lib/python3.7/site-packages/django/db/backends/base/base.py", line 197, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/Users/jesse.kleve/src/playgrounds/django/dori/api/venv/lib/python3.7/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/Users/jesse.kleve/src/playgrounds/django/dori/api/venv/lib/python3.7/site-packages/django/db/backends/postgresql/base.py", line 185, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/Users/jesse.kleve/src/playgrounds/django/dori/api/venv/lib/python3.7/site-packages/psycopg2/__init__.py", line 125, in connect
    dsn = _ext.make_dsn(dsn, **kwargs)
  File "/Users/jesse.kleve/src/playgrounds/django/dori/api/venv/lib/python3.7/site-packages/psycopg2/extensions.py", line 174, in make_dsn
    parse_dsn(dsn)
psycopg2.ProgrammingError: invalid dsn: invalid connection option "init_command"

It seems to be using the wrong backend. It's using 'django.db.backends.postgresql_psycopg2' with DATABASE_URL='postgres://root:toor@127.0.0.1:5432/django'.

This is with Django version 3.0

jkleve commented 4 years ago

It appears this is fixed in master?

Any plan for the next release?

ovnicraft commented 4 years ago

@jkleve do you know where is the fix in master ? to check if it possible a backport

wsvincent commented 4 years ago

Hi y'all,

This issue should be closed. This package is handling it correctly. Since Django 1.9, the alias django.db.backends.postgresql has been used instead of django.db.backends.postgresql_psycogp2. You can see that in the dj_database_url.py file and read more in the Django 2.0 release notes.

jkleve commented 4 years ago

@wsvincent I see the fix on master but the latest release (0.5.0) does not include the fix.

Right? Or am I missing something? 0.5.0 master

jkleve commented 4 years ago

@ovnicraft Sorry missed your comment. See "master" link above.

amrishparmar commented 4 years ago

I'm running into the same issue at the moment. Any chance of a new release? As already mentioned, the current PyPI version (0.5.0) is still using the old behaviour, even though this is fixed on master.

Moulde commented 3 years ago

You can optionally install the package directly from git like so git+https://github.com/jacobian/dj-database-url.git#egg=dj_database_url

alexanderGerbik commented 2 years ago

The new version https://pypi.org/project/dj-database-url/1.0.0/ is out on pypi, which includes the fix, so the issue can be closed.