Ticket #1504: templates_python.txt.diff

File templates_python.txt.diff, 1.5 KB (added by anonymous, 11 years ago)
  • templates_python.txt

    555555Django uses the template loaders in order according to the ``TEMPLATE_LOADERS``
    556556setting. It uses each loader until a loader finds a match.
     558The ``render_to_response()`` shortcut
     561Django provides a shortcut, ``django.shortcuts.render_to_response``, for loading a template, filling
     562its context, and returning `an HttpResponse object`_.
     564**Required arguments:**
     566    ``template``
     567        The full name of a template to use.
     569**Optional arguments:**
     571    ``context``
     572        A dictionary of values to add to the template
     573        context. By default, this is an empty dictionary. If a value in the
     574        dictionary is callable, the view will call it just before rendering
     575        the template.
     577    ``mimetype``
     578        The MIME type to use for the resulting document. Defaults
     579        to the value of the ``DEFAULT_CONTENT_TYPE`` setting.
     583The following example renders the template ``myapp/index.html`` with the mimetype ``application/xhtml+xml``::
     585    from django.shortcuts import render_to_response
     587    my_view(request):
     588        # View code here
     589        return render_to_response("myapp/index.html", {"foo": "bar"}, mimetype="application/xhtml+xml")
     591.. _an HttpResponse object: ../request_response/#httpresponse-objects
    558593Extending the template system
Back to Top