在条件满足时更改Django模板中的值

问题描述 投票:0回答:1

[我要做的是,当充满该标签后面的条件时,包含文本“ Pendiente ...”的表中的最后一个td标签更改为“ Finalizado”,我试图在该条件内插入,但这会只需添加另一个td,当我想要的只是更改其中的文本!我可以帮忙吗?

模板

{%extends 'base.html'%}
{%load staticfiles%}
{%block body_block%}
<link rel="stylesheet" href="{%static 'appointments/css/appointments_index.css'%}">
    {%if consults%}
    <h1 id="Heading">Consultas <h5  id="Date">{% now "j F Y" %}</h5></h1>
        <table align="center">
            <thead>
                <th>Codigo de Paciente</th>
                <th>Paciente</th>
                <th>Fecha</th>
                <th>Motivo</th>
                <th>Padecimiento</th>
                <th>Estado</th>
            </thead>
            <tbody>
                {%for consult in consults%}
                        <tr>
                            <td>{{consult.Paciente.Codigo}}</td>
                            <td>{{consult.Paciente.Nombres}} {{consult.Paciente.Apellidos}}</td>
                            <td>{{consult.Fecha}}</td>
                            <td>{{consult.Motivo}}</td>
                            <td>{{consult.Padecimiento}}</td>
                            <td>Pendiente...</td>
                            <td><div class="perform"><a href="{%url 'appointmentupdate' consult.id %}">Realizar</a></div></td>
                            {% if consult.Medicamento%}
                                <td><div class="receipt"><a href="">Receta</a></div></td>
                            {%endif%}
                        </tr>
                {%endfor%}
            </tbody>
        </table>
        {% if is_paginated %}
        <div class="pagination">
            <span class="page-links">
                {% if page_obj.has_previous %}
                    <a href="/patients?page={{ page_obj.previous_page_number }}">Anterior</a>
                {% endif %}
                <span class="page-current">
                    Pag {{ page_obj.number }} de  {{ page_obj.paginator.num_pages }}.
                </span>
                {% if page_obj.has_next %}
                    <a href="/patients?page={{ page_obj.next_page_number }}">Siguiente</a>
                {% endif %}
            </span>
        </div>
        {% endif %}

    {%else%}
    <h1 id="noregisters">No tiene consultas pendientes.</h1>
    {%endif%}

    <button id="Add"><a class="fas fa-plus" href="{%url 'addappointment'%}"></a></button>
    <button id="Registers"><a href="{%url 'appointmentlist'%}">Registros</a></button>
{%endblock%}
python django
1个回答
1
投票

怎么样:

© www.soinside.com 2019 - 2024. All rights reserved.