waliki
waliki copied to clipboard
Redirections should apply to any view with slug
currently only detail handle redirections, prepending a code like this
# handle redirects first
try:
redirect = Redirect.objects.get(old_slug=slug) # noqa
if redirect.status_code == 302:
return HttpResponseRedirect(redirect.get_absolute_url())
return HttpResponsePermanentRedirect(redirect.get_absolute_url())
except Redirect.DoesNotExist:
pass
this should be a decorator applied to every view based on the "slug" pattern.
So, for example, if there is a redirection from 'slug' to 'new-slug', any of this should work:
-
../slug/raw->../new-slug/raw -
../slug/edit-> `../new-slug/edit -
../slug/version/X->../new-slug/version/X
and so on