Reputation: 483
I'm writing a middleware with process_view
method and I want it to apply only to the views in my app (not django.contrib.auth
and other imported ones). How can this be done?
Upvotes: 1
Views: 167
Reputation: 1950
you can use request url like this
def process_request(self, request):
if request.path.startswith('any_prefix'):
# do something
else:
# do other thing
also you can get view function file like this:
process_view(request, view_func, view_args, view_kwargs):
if view_func.__module__ in ['module list']:
# do something
else:
# do other thing
in this solution if your view wrapped checking module may not work.
Upvotes: 1