Opened 7 years ago

Closed 3 years ago

#8135 closed New feature (wontfix)

Make RequestContext act as a dictionary

Reported by: garcia_marc 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 7 years ago by mk

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 7 years ago by ericholscher

  • milestone set to post-1.0
  • Triage Stage changed from Unreviewed to Design decision needed

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

comment:3 Changed 7 years ago by julien

  • Triage Stage changed from Design decision needed to Accepted

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

comment:4 Changed 7 years ago by julien

  • Triage Stage changed from Accepted to Design 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 7 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:6 Changed 4 years ago by lukeplant

  • Severity set to Normal
  • Type set to New feature

comment:7 Changed 4 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:8 Changed 4 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:9 Changed 3 years ago by apollo13

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

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