render_to_response decorator

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext


def render_response(func):
    def inner(request, *args, **kwargs):
        result = func(request, *args, **kwargs)
        if isinstance(result, HttpResponse):
            return result
        
        template, dictionary = result
        return render_to_response(template, dictionary,
            context_instance=RequestContext(request))
    return inner

More like this

  1. Better render_to_response by SmileyChris 6 years, 1 month ago
  2. Detect iPhone & Switch Template via render_to_response by bryanhelmig 2 years, 12 months ago
  3. simplified render_to_response with RequestContext by jasongreen 3 years, 4 months ago
  4. render_to by asolovyov 4 years, 11 months ago
  5. Caching XHTML render_to_response by smoonen 4 years, 10 months ago

Comments

(Forgotten your password?)