Is it able to nest block in a conditional tag in the template of Django 1.3?

47 lượt xem
Chuyển tới thư đầu tiên chưa đọc

Patto

chưa đọc,
02:20:21 29 thg 2, 201229/2/12
đến django...@googlegroups.com
Here is my need:

{% if request.user.is_csr %}
      {% block csr_block %}



{% endif %}

Tom Evans

chưa đọc,
07:29:28 29 thg 2, 201229/2/12
đến django...@googlegroups.com

No. Inside child templates, most nodes outside of blocks are ignored.
You can do this instead:

{% block csr_block %}
{% if request.user.is_csr %}
...
{% else %}
{{ block.super }}
{% endif %}
{% endblock %}

Cheers

Tom

Trả lời tất cả
Trả lời tác giả
Chuyển tiếp
0 tin nhắn mới