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

标签 python html django button hyperlink

单击“批准”按钮时禁用“拒绝”按钮的最佳方法是什么?我有 {{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/

相关文章:

python - 如何分配属于不同人群的不确定性?

javascript - Knockout JS过滤

django - 在保存之前将数据添加到 Django 表单?

python - del_user() 缺少 1 个必需的位置参数 : 'username' - Django

python - 在 Openpyxl Python 中将列格式设置为百分比

python - 优化二维数组中所有元素的舍入

jquery - 一些带有占位符的 div

html - 为什么看不到这个小部件?WordPress

django - 捕获所有错误并显示错误类型和消息

python - 使用 'datetime64[ns]' 格式从 pandas 数据帧中提取