2👍
✅
There is no way to get request instance in request_finished
signal, because according to the docs the only argument that is sent with this signal is sender
sender
The handler class – e.g. django.core.handlers.wsgi.WsgiHandler – that handled the request.
Note that in sender you receive a class of sender, not an instance.
You can write custom middleware with process_response()
method in order to be able to check request options, like this:
class MyCustomMiddleware(object):
def process_response(self, request, response):
if request.something == 'something':
# do something
return None
Then put MyCustomMiddleware
in MIDDLEWARE_CLASSES in settings file. Position doesn’t matter in that case, because in response cycle request already formed.
Source:stackexchange.com