diff --git a/scopedsites/middleware.py b/scopedsites/middleware.py index 8b2ef25..2ca3049 100644 --- a/scopedsites/middleware.py +++ b/scopedsites/middleware.py @@ -1,3 +1,4 @@ +from asgiref.sync import sync_to_async from django.http import Http404 from django.utils.deprecation import MiddlewareMixin from django_scopes import scope @@ -6,11 +7,15 @@ from scopedsites.models import Domain class DomainScopeMiddleware(MiddlewareMixin): + async def __acall__(self, request): + d = await sync_to_async(Domain.get_from_request)(request) + with scope(domain=d): + return await super().__acall__(request) + def __call__(self, request): d = Domain.get_from_request(request) - with scope(domain=d): - return super()(request) + return super().__call__(request) class DomainAutoCreateMiddleware(MiddlewareMixin): diff --git a/setup.py b/setup.py index a048186..b5c2dd2 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup( name="django_scopedsites", packages=["scopedsites", "scopedsites.migrations"], - version="0.1.7", + version="0.1.8", description="django_scopes x django.contrib.sites", python_requires=">=3.6", install_requires=[