Code:
from django.shortcuts import render_to_response from django.template import RequestContext def render_to(tmpl): def renderer(func): def wrapper(request, *args, **kw): output = func(request, *args, **kw) if not isinstance(output, dict): return output return render_to_response(tmpl, output, context_instance=RequestContext(request)) return wrapper return renderer
Usage:
@render_to('cool/template.html') def view(request): if something: return HttpResponseRedirect('/') else: return {'people': people, 'things': things}
Last modified
18 years ago
Last modified on Feb 19, 2007, 8:43:07 AM
Note:
See TracWiki
for help on using the wiki.