You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@register.simple_tag(takes_context=True)
def render_page_contents(context):
page = context['page']
html = ''
for pc in page.page_contents.all():
if pc.template:
html += render_to_string(pc.template, RequestContext({'page_content': pc}))
return mark_safe(html)
You must enable the 'sekizai.context_processors.sekizai' template context processor or use 'sekizai.context.SekizaiContext' to render your templates.
The context processor is added and I'm using RequestContext, like docs says:
For Django versions after 1.10, add sekizai.context_processors.sekizai to your TEMPLATES['OPTIONS']['context_processors'] setting and use django.template.RequestContext when rendering your templates.
I'm using Django 1.10.8 and django-sekizai 0.10.0
The text was updated successfully, but these errors were encountered:
render_to_string(pc.template, RequestContext({'page_content': pc})) the note about using RequestContext is meant for your main view. Once you start rendering a template, you need to keep the context around, even for sub-templates. You can work around it using:
from sekizai.helpers import get_varname
...
render_to_string(pc.template, Context({'page_content': pc, get_varname(): context[get_varname()]})
I've added sekizai context processor:
I have this custom tag:
A template rendered above:
The base.html contains:
I obtain this error:
The context processor is added and I'm using RequestContext, like docs says:
I'm using Django 1.10.8 and django-sekizai 0.10.0
The text was updated successfully, but these errors were encountered: