In Django 1.8, RequestContext() no longer returns a context with a 'request' key until it is "bound" to a template:
>>> from django.test.client import RequestFactory
>>> from django.template import RequestContext
>>> req = RequestFactory().get('/admin/')
>>> req
<WSGIRequest: GET '/admin/'>
>>> context = RequestContext(req)
>>> context
[{'False': False, 'None': None, 'True': True}, {}, {}]
I'm working with a third-party plugin that does the following (to maintain a content cache):
context = RequestContext(request)
content = render_placeholder(entry.content_placeholder, context)
render_placeholder (from cms.plugin_rendering) accesses context['request'] right at the top, and generates a KeyError exception. I could fix the plugin code like this:
context = RequestContext(request)
with context.bind_template(template):
content = render_placeholder(entry.content_placeholder, context)
But Placeholders do not have a template. It seems to me that render_placeholder ought to take an optional request parameter:
def render_placeholder(placeholder, context_to_copy, name_fallback="Placeholder",
lang=None, default=None, editable=True, use_cache=True, request=None):
...
context = context_to_copy.new(context_to_copy)
context.push()
if not request:
if 'request' in context:
request = context['request']
...
Any suggestions for how to fix this? Did I miss something?
John