diff options
Diffstat (limited to 'docs/topics/http')
| -rw-r--r-- | docs/topics/http/shortcuts.txt | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/docs/topics/http/shortcuts.txt b/docs/topics/http/shortcuts.txt index 8a80affb2a..27e8817884 100644 --- a/docs/topics/http/shortcuts.txt +++ b/docs/topics/http/shortcuts.txt @@ -15,7 +15,7 @@ introduce controlled coupling for convenience's sake. ``render`` ========== -.. function:: render(request, template_name[, dictionary][, context_instance][, content_type][, status][, current_app]) +.. function:: render(request, template_name[, dictionary][, context_instance][, content_type][, status][, current_app][, dirs]) Combines a given template with a given context dictionary and returns an :class:`~django.http.HttpResponse` object with that rendered text. @@ -58,6 +58,13 @@ Optional arguments :ref:`namespaced URL resolution strategy <topics-http-reversing-url-namespaces>` for more information. +``dirs`` + A tuple or list of values to override the :setting:`TEMPLATE_DIRS` setting. + +.. versionchanged:: 1.7 + + The ``dirs`` parameter was added. + Example ------- @@ -83,11 +90,19 @@ This example is equivalent to:: return HttpResponse(t.render(c), content_type="application/xhtml+xml") +If you want to override the :setting:`TEMPLATE_DIRS` setting, use the +``dirs`` parameter:: + + from django.shortcuts import render + + def my_view(request): + # View code here... + return render(request, 'index.html', dirs=('custom_templates',)) ``render_to_response`` ====================== -.. function:: render_to_response(template_name[, dictionary][, context_instance][, content_type]) +.. function:: render_to_response(template_name[, dictionary][, context_instance][, content_type][, dirs]) Renders a given template with a given context dictionary and returns an :class:`~django.http.HttpResponse` object with that rendered text. @@ -125,6 +140,13 @@ Optional arguments The MIME type to use for the resulting document. Defaults to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. +``dirs`` + A tuple or list of values to override the :setting:`TEMPLATE_DIRS` setting. + +.. versionchanged:: 1.7 + + The ``dirs`` parameter was added. + Example ------- @@ -150,6 +172,15 @@ This example is equivalent to:: return HttpResponse(t.render(c), content_type="application/xhtml+xml") +If you want to override the :setting:`TEMPLATE_DIRS` setting, use the +``dirs`` parameter:: + + from django.shortcuts import render_to_response + + def my_view(request): + # View code here... + return render_to_response('index.html', dirs=('custom_templates',)) + ``redirect`` ============ |
