Django / sekizai / classytags templates throw error about endif tag

322 views Asked by At

The error is: Invalid block tag: 'endif'.

First about what the error is about - i wrapped whole template into condition:

{% if something %}
{% else %}
{% load cms_tags sekizai_tags menu_tags %}
{% render_block "css" %}
{% render_block "js" %}
{% endif %}

And this causes django to throw error:

TemplateSyntaxError at /mypage/ Invalid block tag: 'endif'

But the problem is clearly with classytags/sekizai as

{% if something %}
{% else %}
<h1>Hello world</h1>
{% endif %}

renders without errors.

Does anyone know how i could avoid this error or fix it?

Now second part - what i am trying to achieve is - i want to display somewhat different HTML page when request is ajax request. The condition should be if request.is_ajax. But if changed to to illustrate my point in clearer way. I am using django-cms and it allows you to only set one template per each page. And this would not be a problem if i could serve same content but with different surrounding html in case of ajax requests, but unfortunately the rendering fails...

1

There are 1 answers

1
phenxd On

Well, it is pretty clear in the documentation that using {% render _block ... %} inside another template tag block is not allowed.

Couldn't you just do that if condition inside the rendered block?

edit: Just noticed the question was not so recent. Oh well. Curious about how you ended up solving your problem...