Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Using with Django 4.1 runserver raises exceptions #12

Open
shangxiao opened this issue Aug 7, 2022 · 2 comments
Open

Using with Django 4.1 runserver raises exceptions #12

shangxiao opened this issue Aug 7, 2022 · 2 comments

Comments

@shangxiao
Copy link

shangxiao commented Aug 7, 2022

This may be related to #5

Setting up django-pgconnection with Django 4.1 causes the following exception when runserver is run:

Traceback (most recent call last):
  File "/path/to/.pyenv/versions/3.10.4/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/path/to/.pyenv/versions/3.10.4/lib/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 137, in inner_run
    self.check_migrations()
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/core/management/base.py", line 564, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/db/migrations/loader.py", line 58, in __init__
    self.build_graph()
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/db/migrations/loader.py", line 235, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/db/migrations/recorder.py", line 81, in applied_migrations
    if self.has_table():
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/db/migrations/recorder.py", line 57, in has_table
    with self.connection.cursor() as cursor:
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/db/backends/base/base.py", line 323, in cursor
    return self._cursor()
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/db/backends/base/base.py", line 299, in _cursor
    self.ensure_connection()
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/db/backends/base/base.py", line 282, in ensure_connection
    self.connect()
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/db/backends/base/base.py", line 247, in connect
    self.check_settings()
  File "/path/to/project/.direnv/python-3.10.4/lib/python3.10/site-packages/django/db/backends/base/base.py", line 271, in check_settings
    if self.settings_dict["TIME_ZONE"] is not None and not settings.USE_TZ:
KeyError: 'TIME_ZONE'
@wesleykendall
Copy link
Member

@shangxiao if you are using dango-pgconnection for pgtrigger or pghistory, the latest version of those libraries drops the pgconnection dependency. I'd recommend upgrading and removing the pgconnection config

A lot of pgconnection's functionality is available in Django connection hooks (see #7 ), and I will likely archive this library.

@adamchainz
Copy link

FYI I believe the issue is likely caused by django/django@13378ad , as part of django/django#15490 . The logic to fill in default arguments in a connection's settings_dict was moved, and I think this interacts badly with the _Databases class.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants