#27258: Context processors are not called when using RequestContext and Django
templates
---------------------------------+--------------------------------------
     Reporter:  Andi Albrecht    |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  Template system  |                  Version:  1.10
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------

Comment (by Andi Albrecht):

 The more I think about it, the more I'm thinking that it's just a
 documentation issue, too. `get_template` shouldn't be used together with
 manually creating a `RequestContext`.

 FWIW, this simple change in `django.template.context.make_context()`
 solves the issue for me (and all existing tests still pass):

 {{{
 diff --git a/django/template/context.py b/django/template/context.py
 index 1e1c391..aff6236 100644
 --- a/django/template/context.py
 +++ b/django/template/context.py
 @@ -268,6 +268,8 @@ def make_context(context, request=None, **kwargs):
      """
      Create a suitable Context from a plain dict and optionally an
 HttpRequest.
      """
 +    if isinstance(context, RequestContext):
 +        return context
      if request is None:
          context = Context(context, **kwargs)
      else:
 }}}

 IMO `make_context` has a strange behavior when called with a
 `RequestContext` instance as `context`. It returns a `Context` instance
 because it assumes that there's no request.

--
Ticket URL: <https://code.djangoproject.com/ticket/27258#comment:4>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/070.6197f860ac77cb55f7636e7423159668%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to