Neat one off redirect

1
2
3
4
5
from django.http import HttpResponseRedirect

urlpatterns += patterns('',
  (r'^my_url$', lambda r: HttpResponseRedirect('http://www.google.com'))
)

More like this

  1. View Redirect Decorators by bryanpieper 2 years, 10 months ago
  2. FlatPageOverrideMiddleware by David 4 years, 5 months ago
  3. Decorator to ease dynamic redirections in Django by david_bgk 4 years, 3 months ago
  4. @url decorator - getting rid of urlpatterns by southern_sun 5 years, 8 months ago
  5. HttpResponseRedirectView - Redirect to a view by adamlofts 4 years, 9 months ago

Comments

mtrichardson (on September 11, 2008):

Why not just use django.views.generic.simple.redirect_to?

#

adamlofts (on September 11, 2008):

I wasn't aware of redirect_to which works equally well.

Having said that: the method above is a little more pleasing colour-wise in my editor and perhaps more intuitive?

#

(Forgotten your password?)