def render_to(template=None, mimetype=None):
 def renderer(function):
  @wraps(function)
  def wrapper(request, *args, **kwargs):
   output = function(request, *args, **kwargs)
   if (not isinstance(output, dict)):
    return output
   tmpl = output.pop('TEMPLATE', template)
   return render_to_response(tmpl, output, context_instance=RequestContext(request), mimetype=mimetype)
  return wrapper
 return renderer

def render_to ( template = None , mimetype = None ) : def renderer ( function ) : @ wraps ( function ) def wrapper ( request , * args , ** kwargs ) : output = function ( request , * args , ** kwargs ) if ( not isinstance ( output , dict ) ) : return output tmpl = output . pop ( 'TEMPLATE' , template ) return render_to_response ( tmpl , output , context_instance = RequestContext ( request ) , mimetype = mimetype ) return wrapper return renderer
decorator for django views that sends returned dict to render_to_response function .