如何從django admin中減去兩個字段值。在這裏,我給我的意見和templtaes從django admin減去兩個字段
views.py
for attendancesheet_info in attendance_sheet:
attendancesheet_info.present_days= attendancesheet_info.working_days - attendancesheet_info.leave_days
模板
</tr>
<tr>
{% for attendancesheet_info in attendance_sheet %}
<tr>
<td>{{ attendancesheet_info.id}}</td>
<td>{{ attendancesheet_info.employeeid}}</td>
<td>{{ attendancesheet_info.employeename}}</td>
<td>{{ attendancesheet_info.working_days}}</td>
<td>{{ attendancesheet_info.leave_days}}</td>
<td>{{ attendancesheet_info.permissions}}</td>
<td>{{ attendancesheet_info.present_days}}</td>
</tr>
{% endfor %}
</tr>
它不calaculating ..just它打印0 .. – Geetha 2014-12-20 04:39:50
如果self.working_days == self.leave_days,它將返回0。 那你在這種情況下,期望? – 2014-12-20 13:35:34
你的模特看起來像什麼。發佈源代碼。 – 2014-12-20 13:37:46