Decorator to ease dynamic redirections in Django

1
2
3
4
5
6
7
8
from django.conf.urls.defaults import *
from django.http import HttpResponsePermanentRedirect

def redirect(url):
    def inner(request, **args):
        redirect_to = '%s?%s' % (url % args, request.GET.urlencode())
        return HttpResponsePermanentRedirect(redirect_to)
    return inner

More like this

  1. Painless link to admin change view for a given object by david_bgk 4 years, 2 months ago
  2. general-purpose django XMLRC dispatcher by teepark 4 years, 3 months ago
  3. @url decorator - getting rid of urlpatterns by southern_sun 5 years, 8 months ago
  4. Simple Age Verification Middleware by eculver 3 years, 9 months ago
  5. Redirect to no slash by grillermo 1 year, 4 months ago

Comments

(Forgotten your password?)