Opened 18 years ago

Closed 18 years ago

#2837 closed enhancement (worksforme)

missing context_instance explanation in the template documentation

Reported by: thomas.rabaix@… Owned by: Jacob
Component: Documentation Version: 0.95
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The documentation about the template engine does not explain how to use custom context processor in a custom view

@@ -301,6 +301,15 @@
 .. _HttpRequest object: http://www.djangoproject.com/documentation/request_response/#httprequest-objects
 .. _TEMPLATE_CONTEXT_PROCESSORS setting: http://www.djangoproject.com/documentation/settings/#template-context-processors
 
+Note : in your custom views, you need to specify the correct context instance in order to access to the variable set
+in your processor. 
+
+   from django import template
+
+   def demo(request):
+       values = {'Invoice': '20061254'}
+       return render_to_response('demo/demo.html', values, context_instance=template.RequestContext(request))
+
 django.core.context_processors.auth
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Change History (4)

comment:1 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

(In [3911]) Fixed #2837 -- Documented the context_instance parameter to
render_to_response().

comment:2 by Yasushi Masuda <ymasuda@…>, 18 years ago

Resolution: fixed
Status: closedreopened

It would be better to mark the note as docutils .. Note:: (or .. admonition:: with a title) directive.

comment:3 by Yasushi Masuda <ymasuda@…>, 18 years ago

In addition, please fix 'my_template'html' in sample code, it should be 'my_template.html'.

comment:4 by Simon G. <dev@…>, 18 years ago

Resolution: worksforme
Status: reopenedclosed
Note: See TracTickets for help on using tickets.
Back to Top