general: make sure context processors are applied in ajax rendering (#10345)
As Django 1.8 now supports several template engines the template context processors are only applied when the context is bound to an actual template; trick it here as a stopgap measure as we continue to support both Django 1.7 and 1.8.
This commit is contained in:
parent
4f68665bcf
commit
130a6c70ec
|
@ -17,6 +17,7 @@
|
|||
import urllib
|
||||
import urlparse
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import logout as auth_logout
|
||||
|
@ -25,7 +26,7 @@ from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
|
|||
from django.http import (Http404, HttpResponse, HttpResponseRedirect,
|
||||
HttpResponsePermanentRedirect)
|
||||
from django.shortcuts import render, resolve_url
|
||||
from django.template import RequestContext
|
||||
from django.template import RequestContext, loader
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.forms.widgets import Media
|
||||
|
||||
|
@ -83,7 +84,16 @@ def ajax_page_cell(request, page_pk, cell_reference):
|
|||
# Cell can pass data through its own __dict__
|
||||
cell.modify_global_context(context, request)
|
||||
|
||||
return HttpResponse(cell.render(context), content_type='text/html')
|
||||
if django.VERSION < (1, 8, 0):
|
||||
return HttpResponse(cell.render(context), content_type='text/html')
|
||||
else:
|
||||
# FIXME: we bind to an existing template to have the list of
|
||||
# context processors applied to the RequestContext; the
|
||||
# CellBase.render() method should be extended to accept an additional
|
||||
# request parameter, to match the new Template::render() signature.
|
||||
template = loader.get_template('combo/page_template.html')
|
||||
with context.bind_template(template.template):
|
||||
return HttpResponse(cell.render(context), content_type='text/html')
|
||||
|
||||
|
||||
def extend_with_locked_placeholders_cells(cells, page, pages):
|
||||
|
|
Loading…
Reference in New Issue