Django admin kullanıcısını zorunlu olarak /admin/ paneline yönlendirmek

Django 250 views Markdown

 

class AdminGirisYaptiMiddleware(object):

def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):

if request.user.is_authenticated and request.user.is_superuser:
if not '/admin/' in request.path:
return HttpResponseRedirect('/admin/')

response = self.get_response(request)
return response
   
Was this helpful?

Thanks for your feedback!

Still Need Help?

The support team is here around the clock for anything you can't find in the knowledge base.