Opened 10 years ago

Closed 5 years ago

#8135 closed New feature (wontfix)

Make RequestContext act as a dictionary

Reported by: Marc Garcia Owned by: nobody
Component: Template system Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When creating the context, using RequestContext to include context processors content, the next doesn't work:

 context = dict(example=value)

instead I can use

 context = requestContext(request)

but I think that also allowing the first case would avoid some confusion.

Change History (9)

comment:1 Changed 10 years ago by Matthias Kestenholz

This ticket makes not much sense to me. The Context is more than a simple dict, it is a stack container offering functions which cannot be easily emulated using a dict.

Although it would be possible to further emulate a dict I think this would send a wrong message to the user. Why would you want to construct a RequestContext, update a dict with it and then again create a Context to render the template?

comment:2 Changed 10 years ago by Eric Holscher

milestone: post-1.0
Triage Stage: UnreviewedDesign decision needed

I ran into this as well, but don't know if it's a "good thing"

comment:3 Changed 10 years ago by Julien Phalip

Triage Stage: Design decision neededAccepted

This is a valid point. The context is generally assumed to be a dictionary, so RequestContext should behave as such.

comment:4 Changed 10 years ago by Julien Phalip

Triage Stage: AcceptedDesign decision needed

Ok, after a second thought, there's an easy way around this:

from django.template import Context
context = Context(dict(example=value))

comment:5 Changed 9 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:6 Changed 7 years ago by Luke Plant

Severity: Normal
Type: New feature

comment:7 Changed 6 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:8 Changed 6 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:9 Changed 5 years ago by Florian Apolloner

Resolution: wontfix
Status: newclosed

I don't see much gain in it -- especially since one usually passes RequestContext as context_instance and not via the normal dict.

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