You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

22 lines
610 B

"""
Middleware utilities and helpers
"""
def get_admin_namespace(request):
"""
Determine the admin namespace based on the request domain.
Returns the appropriate admin namespace for use in reverse() calls.
Usage:
from config.middleware import get_admin_namespace
admin_ns = get_admin_namespace(request)
url = reverse(f'{admin_ns}:model_changelist')
"""
host = request.get_host()
# Check if the request is from Dovoodi domain
if 'dovodi' in host or 'dovoodi' in host:
return 'dovoodi_admin'
else:
return 'imam_javad_admin'