diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index 76a10bbcf0..a6b029efe2 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -569,8 +569,8 @@ against ``dict``:: .. _subclassing-context-requestcontext: -Subclassing ``Context``: ``RequestContext`` -------------------------------------------- +Using ``RequestContext`` +------------------------ .. class:: RequestContext(request, dict_=None, processors=None) @@ -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: