Django Shortcut Functions
Table of Contents

render_to_response

Tip: Use render_to decorator instead of render_to_response. It will make your code cleaner and less error prone.

@render_to('template.html')
def foo(request):
    bar = Bar.object.all()
    return {'bar': bar}
 
# equals to
def foo(request):
    bar = Bar.object.all()
    return render_to_response('template.html',
                              {'bar': bar},
                              context_instance=RequestContext(request))
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.