render decorator

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from django.shortcuts import render_to_response
from django.template import RequestContext
def render_to(template_path):
def decorator(func):
def wrapper(request, *args, **kwargs):
import pdb
#output = pdb.runcall(func, request, *args, **kwargs)
output = func(request, *args, **kwargs)
if not isinstance(output, dict):
return output
return render_to_response(template_path, output,context_instance=RequestContext(request))
return wrapper
return decorator