As the title states I want to use the 'decorator_from_middleware' function from here: https://docs.djangoproject.com/en/2.1/_modules/django/utils/decorators/
However I'm just confued on how to properly use it. I have my custom middleware class and all the normal middleware stuff set up. How would I incorperate this function to be able to use my middleware as a per view basis with the help of a decorator?
Example: Let's say I have some middleware class
class SimpleMiddleware:
def __init__(self, get_response):
self.get_response = get_response
# One-time configuration and initialization.
def __call__(self, request):
# Code to be executed for each request before
# the view (and later middleware) are called.
response = self.get_response(request)
# Code to be executed for each request/response after
# the view is called.
return response
How would I use decorator_from_middleware(middleware_class): and apply it to a particular view?