Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

23 lines (20 sloc) 0.784 kB
from functools import wraps
from django.shortcuts import render_to_response
from django.template import RequestContext
def render_to(template):
"""decorator for rendering views to template"""
def renderer(func):
@wraps(func)
def wrapper(request, *args, **kw):
output = func(request, *args, **kw)
if isinstance(output, (list, tuple)):
return render_to_response(output[1],
output[0],
context_instance=RequestContext(request))
elif isinstance(output, dict):
return render_to_response(template,
output,
context_instance=RequestContext(request))
return output
return wrapper
return renderer
Jump to Line
Something went wrong with that request. Please try again.