django模板表行不折叠

u0sqgete  于 2022-12-01  发布在  Go
关注(0)|答案(1)|浏览(151)

我无法找出折叠表中某些行的错误。
你能告诉我如何纠正它,以便我可以折叠标记为红色的行吗?
我想我把折叠标签放错了地方或者没有再用过?但是我可以在表中使用表吗?

我的模板:

{% extends "base.html" %}
{% block content %}

    <h3><a href="">{% for project in projects %}{{ project.project_name }}{% endfor %}</a></h3>

    <table class="table table-striped table table-bordered table table-hover table table-condensed">
        <tr>
        <td></td>
        <!-- row with zone names -->
        {% for z in zones %}
            <td style="width:40px" align="center">{{ z.zone_name }}</td>
        {% endfor %}
        </tr>

        <!-- rows with stage names -->
        {% for trstage in trstages %}
            <tr>
                <td style="width:40px"><a data-toggle="collapse" href="#collapse{{ trstage }}">{{ trstage.stage_name }}</a></td>
                <!--  row with stage value  -->
                {% for stage in trstage.stages %}
                        {% for zone in zones|dictsort:"zone_name" %}
                            {% if zone == stage.zone %}
                                <td style="width:40px" align="center">{{ stage.substage_sum.sum }}</td>
                            {% endif %}
                        {% endfor %}
                {% endfor %}
            </tr>
            <div id="collapse{{ trstage }}" class="panel-collapse collapse">
                <!-- rows with substages names -->
                {% for trsubstage in trstage.related_trsubstages %}
                <tr>
                    <td>{{ trsubstage.substage_name }}</td>
                <!-- row with substage value -->
                {% for substage in trsubstage.substages_related %}
                    {% for zone in zones %}
                        {% if zone == substage.stage.zone %}
                        <td style="width:40px" align="center">{{ substage.substage_value }}</td>
                        {% endif %}
                    {% endfor %}
                {% endfor %}
                </tr>
                {% endfor %}
            </div>
        {% endfor %}
    </table>
{% endblock %}

下面是我当前模板视图的链接:

lp0sw83n

lp0sw83n1#

试着把你的trstage的id加到div的href和id中。我在我的项目中做了类似的事情,

<div id="{{ trstage.id.value }}" class="panel-collapse collapse">

<a data-toggle="collapse" href="#{{ trstage.id.value }}">{{ trstage.stage_name }}

相关问题