diff options
| author | Jason Pellerin <jpellerin@gmail.com> | 2006-12-04 19:58:49 +0000 |
|---|---|---|
| committer | Jason Pellerin <jpellerin@gmail.com> | 2006-12-04 19:58:49 +0000 |
| commit | 040f2272e0aec724a36e7abda445b61ee065a8f1 (patch) | |
| tree | 8ae714be4e513663470eaf1d3d8026a92a5cd2f8 /docs/templates_python.txt | |
| parent | 2a58209ff2b7c47245c9d12985ac7581e97988d1 (diff) | |
[multi-db] Merged trunk to 3950. Some tests still failing.
git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@4155 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/templates_python.txt')
| -rw-r--r-- | docs/templates_python.txt | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/docs/templates_python.txt b/docs/templates_python.txt index 8129b209c7..ae2582d7b8 100644 --- a/docs/templates_python.txt +++ b/docs/templates_python.txt @@ -212,6 +212,21 @@ template tags. If an invalid variable is provided to one of these template tags, the variable will be interpreted as ``None``. Filters are always applied to invalid variables within these template tags. +.. admonition:: For debug purposes only! + + While ``TEMPLATE_STRING_IF_INVALID`` can be a useful debugging tool, + it is a bad idea to turn it on as a 'development default'. + + Many templates, including those in the Admin site, rely upon the + silence of the template system when a non-existent variable is + encountered. If you assign a value other than ``''`` to + ``TEMPLATE_STRING_IF_INVALID``, you will experience rendering + problems with these templates and sites. + + Generally, ``TEMPLATE_STRING_IF_INVALID`` should only be enabled + in order to debug a specific template problem, then cleared + once debugging is complete. + Playing with Context objects ---------------------------- @@ -296,6 +311,20 @@ optional, third positional argument, ``processors``. In this example, the 'foo': 'bar', }, [ip_address_processor]) +Note:: + If you're using Django's ``render_to_response()`` shortcut to populate a + template with the contents of a dictionary, your template will be passed a + ``Context`` instance by default (not a ``RequestContext``). To use a + ``RequestContext`` in your template rendering, pass an optional third + argument to ``render_to_response()``: a ``RequestContext`` + instance. Your code might look like this:: + + def some_view(request): + # ... + return render_to_response('my_template'html', + my_data_dictionary, + context_instance=RequestContext(request)) + Here's what each of the default processors does: .. _HttpRequest object: http://www.djangoproject.com/documentation/request_response/#httprequest-objects @@ -1063,7 +1092,7 @@ Configuring the template system in standalone mode .. note:: This section is only of interest to people trying to use the template - system as an output component in another application. If you are using the + system as an output component in another application. If you're using the template system as part of a Django application, nothing here applies to you. @@ -1080,7 +1109,7 @@ described in the `settings file`_ documentation. Simply import the appropriate pieces of the templating system and then, *before* you call any of the templating functions, call ``django.conf.settings.configure()`` with any settings you wish to specify. You might want to consider setting at least -``TEMPLATE_DIRS`` (if you are going to use template loaders), +``TEMPLATE_DIRS`` (if you're going to use template loaders), ``DEFAULT_CHARSET`` (although the default of ``utf-8`` is probably fine) and ``TEMPLATE_DEBUG``. All available settings are described in the `settings documentation`_, and any setting starting with *TEMPLATE_* |
