X
X

Select Your Currency

Türk Lirası $ US Dollar
X
X

Select Your Currency

Türk Lirası $ US Dollar
Yıllık Satın Alımlarda %15 İndirim: Şimdi Tasarruf Edin! Detaylı Bilgi İçin Tıklayın!

Knowledge Base

HomepageKnowledge BaseGeneralDjango Middleware Link Redirection

Django Middleware Link Redirection

You can use the example below to redirect links in special cases with Django Middleware.

To give an example, let's prevent the admin user from accessing the private panel link with Django Middleware.

from django.shortcuts import redirect


class SuperuserControl:

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

def __call__(self, request):
path = request.path_info

if request.user.is_superuser and '/panel/' in path:
return redirect('/admin/')

response = self.get_response(request)

return response

Can't find the information you're looking for?

You have examined the knowledge base in detail, but if you cannot find the information you need,

Create a Support Ticket
Did you find it useful?
(91 times viewed. / 0 people found helpful.)