Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from django.contrib.auth.models import AnonymousUser
from django.test.client import RequestFactory
from sekizai.context import SekizaiContext
from cms.toolbar.toolbar import CMSToolbar
def get_request(path='/'):
request = RequestFactory().get(path)
request.current_page = None
request.session = {'cms_edit': False}
request.user = AnonymousUser()
request.LANGUAGE_CODE = plugin.language
request.toolbar = CMSToolbar(request)
return request
def render_plugin(plugin):
request = get_request()
renderer = request.toolbar.content_renderer
context = SekizaiContext()
context['request'] = request
return renderer.render_plugin(plugin, context, editable=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment