question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django 3.0+ Uses deprecated postgresql_psycopg2 package

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
amrishparmarcommented, Jul 28, 2020

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.

2reactions
alexanderGerbikcommented, Aug 9, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'django.db.backends.postgresql_psycopg2' not working in ...
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.
Read more >
Django 3.0+ Uses deprecated postgresql_psycopg2 package
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: ...
Read more >
Django 3.0 release notes
We've dropped some features that have reached the end of their deprecation cycle, and we've begun the deprecation process for some features. See ......
Read more >
How to Start Django Project with a Database(PostgreSQL)
Let's get started !! 1. Create a directory, and virtual environment. Create a project directory, in this case I use “django-postgres”.
Read more >
django-deprecate-fields - PyPI
This package allows deprecating model fields and allows removing them in a ... Usage. Assume the simple following model: from django.db import models...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found