4๐
โ
A nice place to figure what is the current view is the process_view() middleware method, which also happens to be a great place to add a request variable. E.g.:
class CurrentViewApplicationName(object):
def process_view(self, request, view_func, view_args, view_kwargs):
request.current_app = view_func.__module__.split('.')[0]
Will set request.current_app to testapp
if view_func is testapp.views.some_view
. It might not be bullet proof, some apps have views in submodules etc โฆ But this should be a nice starter for you to tweak to your project specific needs.
๐คjpic
Source:stackexchange.com