Yes - but it doesn’t depend on some hidden feature of Django. It’s
A Django View is just a function that accepts a request + args, and returns a response. That view can, itself, call other functions - including other functions that can act as views. So, you could write a “switch statement” view:
def switch_view(request, arg1, arg2):
if client_app_name == ‘xxx’:
return xxx.view(request, arg1, arg2)
else:
return base_view(request, arg1, arg2)
The logic of exactly how to manage the “switch” is entirely up to you.
Depending on how you set up your client sub-packages, you might even be able to use import logic to your advantage:
def switch_view(request, arg1, arg2):
try:
client_module = importlib.import_module(‘project.%s.emailer.view’ % client_name)
return client_module.view(request, arg1, arg2)
except ImportError:
return base_view(request, arg1, arg2)