擅长:python、mysql、java
<p>您可以添加一个助手函数</p>
<pre><code>helper.py
def get_overtime_application_hours(start_time, end_time) -> int:
difference = end_time - start_time
hours = difference.seconds/3600
return hours
</code></pre>
<p>在模型中导入</p>
<pre><code>from .healper import get_overtime_application_hours
</code></pre>
<p>然后</p>
<pre><code>def duration(self):
hours = get_overtime_application_hours(self.out,
self._in)
return round(hours)
</code></pre>