diff options
| author | Silvan Spross <silvan.spross@gmail.com> | 2013-05-19 11:44:34 +0200 |
|---|---|---|
| committer | Silvan Spross <silvan.spross@gmail.com> | 2013-05-19 13:29:38 +0200 |
| commit | 7264e5c66110b6748b1d40ee3b0d511c71f3232f (patch) | |
| tree | d5e32ee25c56e6fe61f2a18eb8026ec59a1dbc1d /docs/ref | |
| parent | a7e2835276b212425dc07251c833b406304ab1a4 (diff) | |
Add missing imports and models to the examples in the template layer documentation
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/templates/api.txt | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index 677aa13cbb..160cdc7194 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -286,6 +286,7 @@ fully-populated dictionary to ``Context()``. But you can add and delete items from a ``Context`` object once it's been instantiated, too, using standard dictionary syntax:: + >>> from django.template import Context >>> c = Context({"foo": "bar"}) >>> c['foo'] 'bar' @@ -397,6 +398,9 @@ Also, you can give ``RequestContext`` a list of additional processors, using the optional, third positional argument, ``processors``. In this example, the ``RequestContext`` instance gets a ``ip_address`` variable:: + from django.http import HttpResponse + from django.template import RequestContext + def ip_address_processor(request): return {'ip_address': request.META['REMOTE_ADDR']} @@ -417,6 +421,9 @@ optional, third positional argument, ``processors``. In this example, the :func:`~django.shortcuts.render_to_response()`: a ``RequestContext`` instance. Your code might look like this:: + from django.shortcuts import render_to_response + from django.template import RequestContext + def some_view(request): # ... return render_to_response('my_template.html', |
