how to move page to another page in python

581 views python

I'm new in python web development and not playing with some web frameworks like django in python for now. Now, is there a way like PHP (e.g. header("Location:")) that to move the page to another in python?

answered question

you can add redirect url to the 'Location' header of the request object

1 Answer


For Django 1.3+

from django.views.generic import RedirectView

urlpatterns = patterns('',
    (r'^one/$', RedirectView.as_view(url='/another/')),

for earlier version it was: from django.views.generic.simple import redirect_to

urlpatterns = patterns('',
    (r'^one/$', redirect_to, {'url': '/another/'}),

posted this

Have an answer?


Please login first before posting an answer.