Ticket #5484: 5484.2.diff

File 5484.2.diff, 1.7 KB (added by ubernostrum, 8 years ago)

Patch which links to new shortcuts documentation for render_to_response

  • docs/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_string()`` shortcut
     561To cut down on the repetitive nature of loading and rendering
     562templates, Django provides a shortcut function which largely
     563automates the process: ``render_to_string()`` in
     564``django.template.loader``, which loads a template, renders it and
     565returns the resulting string::
     567    from django.template.loader import render_to_string
     568    rendered = render_to_string('my_template.html', { 'foo': 'bar' })
     570The ``render_to_string`` shortcut takes one required argument --
     571``template_name``, which should be the name of the template to load
     572and render -- and two optional arguments::
     574    dictionary
     575        A dictionary to be used as variables and values for the
     576        template's context. This can also be passed as the second
     577        positional argument.
     579    context_instance
     580        An instance of ``Context`` or a subclass (e.g., an instance of
     581        ``RequestContext``) to use as the template's context. This can
     582        also be passed as the third positional argument.
     584See also the `render_to_response()`_ shortcut, which calls
     585``render_to_string`` and feeds the result into an ``HttpResponse``
     586suitable for returning directly from a view.
     588.. _render_to_response(): ../shortcuts/#render-to-response
    558590Extending the template system
Back to Top