gpt4 book ai didi

python - 如何禁用充当链接django的按钮

转载 作者:行者123 更新时间:2023-11-30 22:30:42 25 4
gpt4 key购买 nike

单击“批准”按钮时禁用“拒绝”按钮的最佳方法是什么?我有 {{some}} 存储批准或拒绝值的值。

<a href="{% url 'hrfinance:edit' id=item.id status='a' %}"><button>Approve</button></a> 
<a href="{% url 'hrfinance:edit' id=item.id status='d' %}"><button>Deny</button></a>

html 文件

{% if some %}
<table id="example" class="display" cellspacing="0" width="100%" border="1.5px">
<tr align="center">
<th> Student ID </th>
<th> Student Name </th>
<th> Start Date </th>
<th> End Date </th>
<th> Action </th>
<th> Status </th>
</tr>
{% for item in query_results %}
<tr align="center">
<td> {{item.studentID}} </td>
<td> {{item.studentName}} </td>
<td> {{item.startDate|date:'d-m-Y'}} </td>
<td> {{item.endDate|date:'d-m-Y'}} </td>
<td><a href="{% url 'hrfinance:edit' id=item.id status='a' %}"><button>Approve</button></a> <a href="{% url 'hrfinance:edit' id=item.id status='d' %}"><button {% if some == 'approve' %} disabled{% endif %}>Deny</button></a></td>
<td>
{% if item.status %}
{{item.status}}
{% else %}
Pending
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% else %}

{{some}} 从这里出发

View .py

def superltimesheet(request):
query_results = Timesheet.objects.all()
data={'query_results':query_results, 'some':'some'}
return render(request, 'hrfinance/supervisor_list_timesheet.html', data)

最佳答案

使用if tag :

<button{% if some == 'deny' %} disabled{% endif %}>Approve</button>

关于python - 如何禁用充当链接django的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45972327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com