class LoginRequiredMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
return response
def process_view(self, request, view_func, view_args, view_kwargs):
assert hasattr(request, 'user')
path = request.path_info.lstrip('/')
url_is_exempt = any(url.match(path) for url in EXEMPT_URLS)
if path == reverse('accounts:logout').lstrip('/'):
logout(request)
if request.user.is_authenticated() and url_is_exempt:
return redirect(settings.LOGIN_REDIRECT_URL)
elif request.user.is_authenticated() or url_is_exempt:
return None
else:
return redirect(settings.LOGIN_URL)
class MyAuthorization:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
return response
def process_request(self, request):
if not request.user.is_authenticated():
return HttpResponseRedirect('/') # or http response
return None
{"ok":true,
"result":[]}
Это тоже не совсем то что нужно,
Нужно как отфильтровать группу где есть только item c 'PROMO'