mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #4278 -- Added a dirs parameter to a few functions to override TEMPLATE_DIRS.
* django.template.loader.get_template() * django.template.loader.select_template() * django.shortcuts.render() * django.shortcuts.render_to_response() Thanks amcnabb for the suggestion.
This commit is contained in:
committed by
Tim Graham
parent
893198509e
commit
2f0566fa61
@@ -594,17 +594,31 @@ The Python API
|
||||
|
||||
``django.template.loader`` has two functions to load templates from files:
|
||||
|
||||
.. function:: get_template(template_name)
|
||||
.. function:: get_template(template_name[, dirs])
|
||||
|
||||
``get_template`` returns the compiled template (a ``Template`` object) for
|
||||
the template with the given name. If the template doesn't exist, it raises
|
||||
``django.template.TemplateDoesNotExist``.
|
||||
|
||||
.. function:: select_template(template_name_list)
|
||||
To override the :setting:`TEMPLATE_DIRS` setting, use the ``dirs``
|
||||
parameter. The ``dirs`` parameter may be a tuple or list.
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
|
||||
The ``dirs`` parameter was added.
|
||||
|
||||
.. function:: select_template(template_name_list[, dirs])
|
||||
|
||||
``select_template`` is just like ``get_template``, except it takes a list
|
||||
of template names. Of the list, it returns the first template that exists.
|
||||
|
||||
To override the :setting:`TEMPLATE_DIRS` setting, use the ``dirs``
|
||||
parameter. The ``dirs`` parameter may be a tuple or list.
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
|
||||
The ``dirs`` parameter was added.
|
||||
|
||||
For example, if you call ``get_template('story_detail.html')`` and have the
|
||||
above :setting:`TEMPLATE_DIRS` setting, here are the files Django will look for,
|
||||
in order:
|
||||
|
||||
Reference in New Issue
Block a user