I managed to solve this issue. I created signal for user_logged_in action, thats add a variable redirect_me=True
. Thats that i had still the same request in middleware, I could check it and make and redirct. Thats a sample code here:
signals.py:
from django.contrib.auth.signals import user_logged_in
def do_stuff(sender, user, request, **kwargs):
if getattr(request, 'user', None) and not request.user.is_superuser:
request.do_stuff = True
models.py (you also can place it in init.py, or other file that is run initially on 'runserver'):
from django.contrib.auth.signals import user_logged_in
user_logged_in.connect(do_stuff)
middleware.py:
class PrimordialAdvertMiddleware(object):
def process_response(self, request, response):
if getattr(request, 'do_stuff', None):
return do_some_other_stuff()
return response
You make a process_request action as well. I hope that it will help someone in future.