Ticket #5484: 5484.diff

File 5484.diff, 2.4 KB (added by James Bennett, 17 years ago)
  • 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.
    557557
     558The ``render_to_string()`` and ``render_to_response()`` shortcuts
     559=================================================================
     560
     561To cut down on the repetitive nature of loading and rendering
     562templates, Django provides two shortcut functions which largely
     563automate the process: ``render_to_string()`` in
     564``django.template.loader`` and ``render_to_response()`` in
     565``django.shortcuts``.
     566
     567``django.template.loader.render_to_string()``
     568---------------------------------------------
     569
     570Renders a template and returns the resulting string.
     571
     572**Required arguments:**
     573
     574    template_name
     575        The name of the template to render. Can also be passed as the
     576        first positional argument.
     577
     578**Optional arguments:**
     579
     580    dictionary
     581        A dictionary to be used as variables and values for the
     582        template's context. Can also be passed as the second
     583        positional argument.
     584
     585    context_instance
     586        An instance of ``Context`` or a subclass (e.g., an instance of
     587        ``RequestContext``) to use as the template's context. Can also
     588        be passed as the third positional argument.
     589
     590``django.shortcuts.render_to_response()``
     591-----------------------------------------
     592
     593Like ``render_to_string``, but returns an ``HttpResponse`` object with
     594the rendered template as its contents.
     595
     596**Required arguments**
     597
     598    template_name
     599        The name of the template to render. Can also be passed as the
     600        first positional argument.
     601
     602**Optional arguments**
     603
     604    dictionary
     605        A dictionary to be used as variables and values for the
     606        template's context. Can also be passed as the second
     607        positional argument.
     608
     609    context_instance
     610        An instance of ``Context`` or a subclass (e.g., an instance of
     611        ``RequestContext``) to use as the template's context. Can also
     612        be passed as the third positional argument.
     613
     614    mimetype
     615        The HTTP Content-Type to use for the ``HttpResponse``. Must be
     616        passed as a keyword argument.
     617
    558618Extending the template system
    559619=============================
    560620
Back to Top