大家好我想创建一个发票。为此我使用django聚合来总结工作时间。代码如下:
class ProjectTask(models.Model):
project_info = models.ForeignKey(ProjectInvitation, blank=True)
name = models.CharField(max_length=50)
description = models.TextField()
scm_id = models.CharField(max_length=10, blank=True, null=True)
estimated_hours = models.DecimalField(max_digits=10,
decimal_places=2)
percent_completed = models.DecimalField(max_digits=10,
decimal_places=2)
worked_hours = models.DecimalField(max_digits=10,
decimal_places=2)
def save(self, *args, **kwargs):
worked_hours = self.estimated_hours * self.percent_completed
super(ProjectTask, self).save(*args, **kwargs)
total = ProjectTask.objects.all().aggregate(Sum('worked_hours'))
问题是我得到RuntimeError(“App注册表还没有准备好。”)。任何想法如何克服它?
答案 0 :(得分:0)