如何删除html页面中的一些特定数据?

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

This data I want to delete

这是我的代码。

{% extends 'app.html' %}

{% block body %}
    <div>
        <div class="alert alert-info">Transaction / Returning</div>

        <table id="table" class="table table-stripped">
            <thead class="alert-success">
            <tr>
                <th>Student Name</th>
                <th>Book Title</th>
                <th>Book Author</th>
                <th>Status</th>
                <th>Date Returned</th>
                <th>Action</th>
            </tr>
            </thead>
            <tbody>
            {% for borrow in borrows %}
                <tr>
                    <td>{{ borrow.student.all.0.firstname }} {{ borrow.student.all.0.lastname }}</td>
                    <td>{{ borrow.book.all.0.title }}</td>
                    <td>{{ borrow.book.all.0.author }}</td>
                    <td>{{ borrow.status }}</td>
                    <td>{{ borrow.date | date }}</td>
                    <td>
                        {% if borrow.status == "Returned" %}
                            <button disabled="disabled" class="btn btn-primary" type="button" href="#">
                                <span class="glyphicon glyphicon-check"></span> Returned
                            </button>
                        {% else %}
                            <form method="POST" action="">
                                {% csrf_token %}
                                <input type="hidden" name="borrow_id" value="{{ borrow.id }}"/>
                                <button class="btn btn-danger">
                                    <span class="glyphicon glyphicon-unchecked"></span> Return
                                </button>
                            </form>
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}

是的,我想让所有的表格保持不变,但在 状态、返回日期、行动 应该被清除。在我的项目中看起来很脏,所以帮我解决这个问题。

html
2个回答
0
投票

您必须删除数据库中的数据才能清除这些条目。


0
投票

要做到这一点,您可在您的 视图.py 文件,它将从你的数据库中删除一个特定的条目,使一切保持不变。

要访问该功能,请在您的html文件中添加一个按钮。

就这样了。

希望对你有所帮助!

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