title: Django Query on parent from child
body: <p>I am new to Python Django and I want to make a query </p>
  
  <pre><code>class A(models.Model):
      foo = models.IntegerField(default=0)
      from_time = models.DateTimeField('start time')
      to_time = models.DateTimeField('end time')
  
  class B(models.Model):
      model_a = models.ForeignKey(A, on_delete=models.PROTECT, related_name='model_a')
      model_c = models.ForeignKey(C, on_delete=models.PROTECT, related_name='model_c')
  
  class C(models.Model):
      id = models.IntegerField(default=0)
      name = models.CharField(max_length = 20)
  </code></pre>
  
  <p>I want to make a query on class B where the current time is in between model_a.from_time and model_a.to_time. for that, I tried </p>
  
  <pre><code>B.objects.filter(model_c=model_c_id, model_a.to_time__gte=start_date, model_a.to_time__lte=end_date)
  </code></pre>
  
  <p>it gives me syntax error <code>SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
  </code></p>