Skip to content

Instantly share code, notes, and snippets.

@willvanwazer

willvanwazer/redirect.py

Last active Dec 15, 2015
Embed
What would you like to do?
Change in Django Redirects
# In Django 1.4, this works fine:
from django.conf.urls.defaults import patterns, include, url
from django.views.generic.simple import redirect_to
urlpatterns = patterns('',
url(r'^redirect/', redirect_to, {'url': 'http://foo'}),
)
# In Django 1.5, it is changed to this:
from django.conf.urls.defaults import patterns, include, url
from django.views.generic import RedirectView
urlpatterns = patterns('',
url(r'^redirect/', RedirectView.as_view(url='http://foo')),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment