Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django admin url redirect to custom url

Tags:

python

url

django

I am in a way of making a module for my project that can be reused later also.

Lets say I have an django app named "demo" and I have included it in root url like url(r'demo/',include("demo.urls")),

Now inside "demo.urls" I want to redirect admin url to custom url.

/admin/auth/group/add/

should be redirected to any url that is of demo.urls

like image 250
varad Avatar asked Dec 03 '25 12:12

varad


1 Answers

define a view function that redirects to your desired url:

from django.http import HttpResponseRedirect

def redirect_to_desired_url(request):
    return HttpResponseRedirect('new_url/')

and then in your urls.py

urlpatterns = patterns('',
 ...
  url(r'^/redirect_to_desired_url/$',redirect_to_desired_url),  
  ...
)
like image 119
Serjik Avatar answered Dec 06 '25 00:12

Serjik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!