开发者

If statement looks to not extend to other templates

开发者 https://www.devze.com 2023-04-12 10:35 出处:网络
I have a problem with one of my if statements on my django template. Currently I have this on my base.html which extends to other templates:

I have a problem with one of my if statements on my django template.

Currently I have this on my base.html which extends to other templates:

base.html

{% if user.is_superuser %}
    <h2>Admin Menu</h2>
    <table>
        <tr>
        {% if approved %}
            <td><开发者_运维知识库a href="{% url rates-disable_rates %}" class="mbbutton ui-state-active ui-corner-all">Disable Rates</a></td>
        {% else %}
            <td><a href="{% url rates-approve_rates %}" class="mbbutton ui-state-active ui-corner-all">Approve Rates</a></td>
        {% endif %}
        </tr>
        {% if life %}
        {% include 'rates/admin_life_rates_menu.html' %}
        {% else %}
        {% include 'rates/admin_broker_rates_menu.html' %}
        {% endif %}
    </table>
{% endif %}

Now I have rates for certain categories, for example X rates, Y rates, etc. Each with their own button.

Example:

<form method="get" action=".">
   <input type="hidden" name="product_code" value="{{ product_code }}"/>
   <input type="hidden" name="paymode_code" value="{{ paymode_code }}"/>
   <input type="hidden" name="compoundmode_code" value="{{ compoundmode_code }}"/>
   {% if life %}<input type="hidden" name="life" value="{{ life }}"/>{% endif %}
   {% if tfsa %}<input type="hidden" name="tfsa" value="{{ tfsa }}"/>{% endif %}
</form>

If rates are approved the link is displayed as 'disable rates' (the reverse, naturally) and vice versa is the rates havent been approved.

So my issue is that the if statement doesn't seem to work when I click to view the other rates.

If the rates are already approved, the link shows approve, even though that is incorrect. Any ideas as to why this if statement wouldn't be working?

Thanks so much and if there is any more code segments I need to display just ask, and I will gladly put them up.


It seems you're not providing the approved variable in your view, so it evaluates to '', which is false.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号