Redirect requests to a given URL using Django

In Django version 1.3+ the built-in RedirectView class can be used to redirect a page.

After adding the URL pattern in the snippet below to your file, requests sent to /somepage/* will be redirected to /anotherpage/

from django.views.generic import RedirectView

urlpatterns = patterns('',
    (r'^somepage/$', RedirectView.as_view(url='/anotherpage/')),

more Django posts

more Python posts