Code

Opened 8 years ago

Closed 7 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: UI/UX:

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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Attachments (0)

Change History (4)

comment:1 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:2 Changed 8 years ago by Yasushi Masuda <ymasuda@…>

  • Resolution fixed deleted
  • Status changed from closed to reopened

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

comment:3 Changed 8 years ago by Yasushi Masuda <ymasuda@…>

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

comment:4 Changed 7 years ago by Simon G. <dev@…>

  • Resolution set to worksforme
  • Status changed from reopened to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.