Django

Code

Ticket #2837 (closed: worksforme)

Opened 2 years ago

Last modified 2 years ago

missing context_instance explanation in the template documentation

Reported by: thomas.rabaix@randomexceptions.com Assigned to: jacob
Milestone: Component: Documentation
Version: 0.95 Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

Change History

10/23/06 02:39:19 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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

10/24/06 07:15:02 changed by Yasushi Masuda <ymasuda@ethercube.com>

  • status changed from closed to reopened.
  • resolution deleted.

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

10/24/06 07:22:27 changed by Yasushi Masuda <ymasuda@ethercube.com>

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

02/21/07 18:18:48 changed by Simon G. <dev@simon.net.nz>

  • status changed from reopened to closed.
  • resolution set to worksforme.

Add/Change #2837 (missing context_instance explanation in the template documentation)




Change Properties
Action