Ticket #1504: templates_python.txt.diff

File templates_python.txt.diff, 1.5 KB (added by anonymous, 17 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.
    557557
     558The ``render_to_response()`` shortcut
     559=====================================
     560
     561Django provides a shortcut, ``django.shortcuts.render_to_response``, for loading a template, filling
     562its context, and returning `an HttpResponse object`_.
     563
     564**Required arguments:**
     565
     566    ``template``
     567        The full name of a template to use.
     568
     569**Optional arguments:**
     570
     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.
     576
     577    ``mimetype``
     578        The MIME type to use for the resulting document. Defaults
     579        to the value of the ``DEFAULT_CONTENT_TYPE`` setting.
     580
     581**Example:**
     582
     583The following example renders the template ``myapp/index.html`` with the mimetype ``application/xhtml+xml``::
     584
     585    from django.shortcuts import render_to_response
     586   
     587    my_view(request):
     588        # View code here
     589        return render_to_response("myapp/index.html", {"foo": "bar"}, mimetype="application/xhtml+xml")
     590   
     591.. _an HttpResponse object: ../request_response/#httpresponse-objects
     592
    558593Extending the template system
    559594=============================
    560595
Back to Top