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. django redirects middleware a bit more fleixble by robertrv 2 years, 7 months ago
  2. Simple Age Verification Middleware by eculver 2 years, 9 months ago
  3. SSL Redirect Middleware by zbyte64 3 years, 10 months ago
  4. Effective content caching for mass-load site using redirect feature by nnseva 10 months, 3 weeks ago
  5. A action decorator for URLs by Batiste 4 years, 1 month ago

Comments

(Forgotten your password?)