Skip to content

Commit

Permalink
Refs #25854 -- Completed a RequestContext docs example.
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Aug 19, 2016
1 parent 518eaf1 commit f8c338e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/ref/templates/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,8 @@ against ``dict``::

.. _subclassing-context-requestcontext:

Subclassing ``Context``: ``RequestContext``
-------------------------------------------
Using ``RequestContext``
------------------------

.. class:: RequestContext(request, dict_=None, processors=None)

Expand Down Expand Up @@ -636,17 +636,17 @@ using the optional, third positional argument, ``processors``. In this
example, the :class:`RequestContext` instance gets a ``ip_address`` variable::

from django.http import HttpResponse
from django.template import RequestContext
from django.template import RequestContext, Template

def ip_address_processor(request):
return {'ip_address': request.META['REMOTE_ADDR']}

def some_view(request):
# ...
c = RequestContext(request, {
'foo': 'bar',
def client_ip_view(request):
template = Template('{{ title }}: {{ ip_address }}')
context = RequestContext(request, {
'title': 'Your IP Address',
}, [ip_address_processor])
return HttpResponse(t.render(c))
return HttpResponse(template.render(context))

.. _context-processors:

Expand Down

0 comments on commit f8c338e

Please sign in to comment.