擅长:python、mysql、java
<p>我可以用一个新的函数来解决这个问题。你知道吗</p>
<pre><code> def total_allocation(self):
a = Allocation.objects.filter(project_id=self.project_id)
total = 0
for i in a:
if i.user_id == self.user_id:
total += i.allocated_hours
return total
</code></pre>
<p>谢谢你的建议。我还是很好奇有没有什么方法可以让我这样做表格.py而不是添加到我的型号.py. 我无法让它工作。你知道吗</p>