#32429: Configurable "always available" InclusionNode context variables
-------------------------------------+-------------------------------------
               Reporter:  Michael    |          Owner:  nobody
  Gisi                               |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Template   |        Version:  3.1
  system                             |       Keywords:  context, inclusion
               Severity:  Normal     |  tag, template
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Currently, the `csrf_token` is always added to the context of an inclusion
 tag. It would be useful to define a list of additional variables that
 should always be available in any context.

 e.g. something like this defined in settings
 {{{#!python
 INCLUSION_CONTEXT_VARIABLES = ['idempotency_key', ]
 }}}

 and a few lines added to the `render` method of `InclusionNode`
 {{{#!python
     def render(self, context):
         ...
         csrf_token = context.get('csrf_token')
         if csrf_token is not None:
             new_context['csrf_token'] = csrf_token
         for var in settings.INCLUSION_CONTEXT_VARIABLES:
             value = context.get(var)
             if value is not None:
                 new_context[var] = value
         return t.render(new_context)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32429>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/047.e320ebef3c529b8e035dc92fd4500aeb%40djangoproject.com.

Reply via email to