This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
cmsplugin-blurp/src/cmsplugin_blurp/views.py

19 lines
612 B
Python

import json
from django.http import HttpResponse
from django.template import RequestContext, loader
from cms.models import CMSPlugin
def ajax_render(request, plugin_id):
plugin = CMSPlugin.objects.get(pk=plugin_id)
context = RequestContext(request)
context['ajaxy'] = False
rendered = plugin.render_plugin(context)
# use another template to render accumulated js and css declarations from sekizai
content = loader.render_to_string('cmsplugin_blurp/sekizai_render.html',
{'content': rendered},
context)
return HttpResponse(json.dumps({'content': content}))