Skip to content

Commit c01319f

Browse files
committed
fix(settings): small fix
To avoid circular imports
1 parent a335b7a commit c01319f

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "cardo-python-utils"
7-
version = "0.5.dev41"
7+
version = "0.5.dev42"
88
description = "Python library enhanced with a wide range of functions for different scenarios."
99
readme = "README.rst"
1010
requires-python = ">=3.8"

python_utils/django/settings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from django.conf import settings
22

33
TENANT_KEY = "tenant"
4-
DATABASES = settings.DATABASES
54
TENANT_DATABASES = set(settings.DATABASES.keys()) - {"default"}
65

76
TENANT_AWARE_EXCLUDED_PATHS = getattr(settings, "TENANT_AWARE_EXCLUDED_PATHS", ())
@@ -20,4 +19,4 @@
2019
if TENANT_DATABASES:
2120
DEVELOPMENT_TENANT = list(TENANT_DATABASES)[0]
2221
else:
23-
DEVELOPMENT_TENANT = list(DATABASES.keys())[0]
22+
DEVELOPMENT_TENANT = list(settings.DATABASES.keys())[0]

python_utils/django/tenant_context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from contextvars import ContextVar
44
from typing import Optional
55

6-
from .settings import DATABASES
6+
from django.conf import settings
77

88
logger = logging.getLogger(__name__)
99

@@ -84,7 +84,7 @@ def set(tenant):
8484
# If the tenant is already set to the same value, we do nothing and return None.
8585
return None
8686

87-
if tenant not in DATABASES:
87+
if tenant not in settings.DATABASES:
8888
raise ValueError(f"Tenant '{tenant}' not found in DATABASES settings.")
8989

9090
token = _tenant_var.set(tenant)

0 commit comments

Comments
 (0)