當我使用{%如果request.user.is_authenticated%}條件在此代碼重定向它拋出錯誤Invalid block tag: 'else'
{% if request.user.is_authenticated %}
{% extends "pages/page.html" %}
{% load mezzanine_tags shop_tags i18n %}
{% block body_id %}category{% endblock %}
{% block main %}{{ block.super }}
{% regroup products by category as products_by_category %}
{% for c in products_by_category %}
......
{% for p in c.list %}
......
{% if p.num_in_stock == None %}
...
{% else %}
{% if p.num_in_stock < 4 %}
...
{% endif %}
{% endif %}
.....
{% endfor %}
......
{% endfor %}
{% endblock %}
{% else %}
<script>
window.location="/stylequiz/";
</script>
如果我使用這個腳本,那麼它不會給出錯誤
{% if request.user.is_authenticated %}
<h1>welcome</h1>
{% else %}
<script>
window.location="/stylequiz/";
</script>
{% endif %}
我想一定有問題嵌套如果。
當然,有些對齊不會傷害.. – 2012-12-13 06:03:54
你會詳細說明你的評論一點.. –
我認爲他的意思是「你的/ endfor,如果/ endif塊不對齊,並且很難閱讀。 – voithos