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. yet another render_to_response decorator by aleks 1 year, 7 months ago
  2. Better render_to_response by SmileyChris 7 years, 1 month ago
  3. render_with decorator by tobias 5 years, 7 months ago
  4. render_to_response wrapper by Magus 7 years, 1 month ago
  5. render_to by asolovyov 5 years, 10 months ago

Comments

(Forgotten your password?)