Opened 12 months ago

Closed 10 months ago

Last modified 10 months ago

#22167 closed Cleanup/optimization (fixed)

docs about order of template context processors unclear

Reported by: anonymous Owned by: erikr
Component: Documentation Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If I do:

return render_to_response('my_template.html',
                              my_data_dictionary,
                              context_instance=RequestContext(request))

then my_data_dictionary will override anything added by the context processors.

The docs state:

"When you use RequestContext, the variables you supply directly are added first, followed any variables supplied by context processors. This means that a context processor may overwrite a variable you’ve supplied"

Which seems to relate to this situation:

return render_to_response('my_template.html',
                              context_instance=RequestContext(request, my_data_dictionary))

This seems inconsistent, could there be an extra note added to clarify what happens when my_data_dictionary is passed to render_to_response instead of RequestContext?

Change History (9)

comment:1 Changed 12 months ago by timo

  • Component changed from Template system to Documentation
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 10 months ago by anonymous

  • Owner changed from nobody to anonymous
  • Status changed from new to assigned

comment:3 Changed 10 months ago by tibidat

  • Owner changed from anonymous to tibidat

Doing this during the DjangoConEu 2014 Sprints.

comment:5 Changed 10 months ago by erikr

  • Owner changed from tibidat to erikr

comment:6 Changed 10 months ago by Erik Romijn <eromijn@…>

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

In e7ffba8f78849fbf60b98fb8d67ef4577b585e3b:

Fixed #22167 -- Improved documentation on context processors

Clarified the explanation on the order in which user provided variables
to render_to_response, RequestContext and context processors are
loaded.

comment:7 Changed 10 months ago by Erik Romijn <eromijn@…>

In bd45139d4e17304229da5464c907c614e64278d1:

[1.7.x] Fixed #22167 -- Improved documentation on context processors

Backport of e7ffba8f78849fbf60b98fb8d67ef4577b585e3b from master.

comment:8 Changed 10 months ago by Erik Romijn <eromijn@…>

In 20215f4cae4f69f2bcbc4bbdbcd84651bee64634:

[1.6.x] Fixed #22167 -- Improved documentation on context processors

Backport of e7ffba8f78849fbf60b98fb8d67ef4577b585e3b from master.

comment:9 Changed 10 months ago by Erik Romijn <eromijn@…>

In 220c09e97acb8ca4267a0b754256e522e008c2d8:

[1.5.x] Fixed #22167 -- Improved documentation on context processors

Backport of e7ffba8f78849fbf60b98fb8d67ef4577b585e3b from master.

Note: See TracTickets for help on using tickets.
Back to Top