def template_render(template, context=None, request=None):
 if isinstance(template, Template):
  if request:
   context = RequestContext(request, context)
  else:
   context = Context(context)
  return template.render(context)
 else:
  return template.render(context, request=request)

def template_render ( template , context = None , request = None ) : if isinstance ( template , Template ) : if request : context = RequestContext ( request , context ) else : context = Context ( context ) return template . render ( context ) else : return template . render ( context , request = request )
passing context or requestcontext to template .