title: compare fields in two different django models
body: <p>I am trying fill a field (hours) in Employee model based on the aggregate of a field (time_worked) in Timesheet model.</p>
  <p>MODELS.PY</p>
  <pre><code>class Employee(models.Model):
      ...
      user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, related_name='employees')
      hours = models.DurationField(null=True, blank=True)
  
  class Timesheet(models.Model):
      user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
      employee    = models.ForeignKey(Employee, on_delete=models.CASCADE, null=True,)
      time_worked = models.DurationField(null=True, blank=True)
  </code></pre>
  <p>I tried <code>hours=Timesheet.objects.filter(employee=employee).aggregate(Sum('time_worked'))</code></p>
  <p>But when I try insert into Employee model that's where I get errors.</p>
  <p>If I do this, <code>Employee.objects.filter(id=employee).update(hours=hours)</code>, I get error &quot;id expected a number but got Jacob&quot;. But id in Timesheet is actually a number (foreignkey).</p>
  <p>How do I add up the <code>time_worked</code> in <code>Timesheet</code> model of only employee A and insert the results into <code>hours</code> column of <code>Employee</code> model for employee A?</p>
  <p>Or simply put, how do I match an employee in Timesheet to an employee in Employee?</p>