Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix utils to not require TENANT_USE_ASGIREF to be defined in the host django project #206

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions django_multitenant/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_tenant_persists_from_async_task_to_thread(self):
account = projects[0].account

with self.settings(TENANT_USE_ASGIREF=True):
importlib.reload(sys.modules["django_multitenant.settings"])
importlib.reload(sys.modules["django_multitenant.utils"])

# Set the tenant in task
Expand All @@ -66,6 +67,7 @@ def test_tenant_persists_from_async_task_to_thread(self):
unset_current_tenant()

with self.settings(TENANT_USE_ASGIREF=False):
importlib.reload(sys.modules["django_multitenant.settings"])
importlib.reload(sys.modules["django_multitenant.utils"])

# Set the tenant in task
Expand Down
4 changes: 2 additions & 2 deletions django_multitenant/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import inspect

from django.apps import apps
from django.conf import settings
from .settings import TENANT_USE_ASGIREF


if settings.TENANT_USE_ASGIREF:
if TENANT_USE_ASGIREF:
# asgiref must be installed, its included with Django >= 3.0
from asgiref.local import Local as local
else:
Expand Down