How do I accomplish a simple redirect (e.g. cflocation
in ColdFusion, or header(location:http://)
for PHP) in Django?
Depending on what you want (i.e. if you do not want to do any additional pre-processing), it is simpler to just use Django's redirect_to
generic view:
from django.views.generic.simple import redirect_to
urlpatterns = patterns('',
(r'^one/$', redirect_to, {'url': '/another/'}),
#etc...
)
See documentation for more advanced examples.
For Django 1.3+ use:
from django.views.generic import RedirectView
urlpatterns = patterns('',
(r'^one/$', RedirectView.as_view(url='/another/')),
)