title: Django filter on calculated field when calculated field returns the value based on combination of two model fields
body: <p>How to filter on calculated field whose values can be decided based on combination of two model fields in the same Model?</p>
  
  <p><strong>Models.py</strong></p>
  
  <pre><code>class Job(models.Model):
      start_time = models.DateTimeField(auto_now_add=True)
      end_time = models.DateTimeField(null=True)
      expiry_time = models.DateTimeField(null=True)
      is_complete = models.BooleanField(default=True)
  
      def _get_job_status(self):
          if self.is_complete is False and self.expiry_time &gt;= now:
              return "active"
          elif self.is_complete is False and self.expiry_time &lt; now:
              return "expired"
          else:
              return "complete"
  
      job_status = property(_get_job_status)
  </code></pre>
  
  <p>I want to filter on job_status field, which can have 3 values active, expired or complete. I can not add job_status field directly in the filter fields, so how to filter on it?</p>
  
  <p><strong>Update1</strong></p>
  
  <p>According to the responses, my above solution is not correct. So, If I try to solve this issue by creating two different filters say <strong>is_complete</strong> and <strong>is_expired</strong>, but still I am not finding the way to specify the queryset for is_complete BooleanFilter. My is_complete = True should give result for the condition <strong>(is_complete is False and expiry_time >= now)</strong> and Is_complete = False should give result for the condition <strong>(is_complete is False and expiry_time &lt; now)</strong> How can I write this query?</p>
  
  <p><strong>filters.py</strong></p>
  
  <pre><code>class JobStatusFilter(FilterSet):
      is_active = filters.BooleanFilter(name="is_complete")
  
      class Meta:
          model = Job
          fields = ('is_complete',)
  </code></pre>