Add from django.core.urlresolvers import reverse
to your list of imports and then try this bit of code:
if slug == 'old-path':
return HttpResponsePermanentRedirect(reverse('new-path'))
The problem you had was that HttpResponsePermanentRedirect()
needs a path but you were providing it with a slug.
reverse()
will search through your named URLs for the string you provide and return a path, which can then be redirected to properly.
John Debs
2009-12-03 10:40:32