title: How to filter queryset based on related objects if it contains data in django
body: <p>I want to filter and get only those data related to its related objects data if only related to its parent object child objects have data. For eg:
  I have the following models:</p>
  
  <pre><code>class Collection(models.Model):
      date_of_collection=models.DateField()
  
  class Product(models.Model):
      name=models.CharField(max_length=100)
      collection = models.ForeignKey(Collection)
  
  class Price(models.Model):
      price = models.FloatField()
      products = models.ForeignKey(Products, on_delete=models.CASCADE)
  </code></pre>
  
  <p>and i have data related to models as:</p>
  
  <pre><code>Collection:
  +----+--------------------+
  | id | date_of_collection |
  +----+--------------------+
  |  1 | 2019-01-17         |
  |  2 | 2019-01-30         |
  |  3 | 2019-02-01         |
  |  4 | 2019-02-02         |
  +----+--------------------+
  
  Products:
  
   +----+--------------------------------+
   | id | name           | collection    |
   +----+--------------------------------+
   |  1 | product 1      | 3             |
   |  2 | product 2      | 1             |
   |  3 | product 3      | 1             |
   |  4 | product 4      | 4             |
   +----+--------------------------------+
  
  Price:
  
  | id     | price            | product               |
  +--------+------------------+-----------------------+
  | 1      | 10.00            | 1                     |
  | 2      | 20.00            | 1                     |
  | 3      | 12.00            | 3                     |
  +--------+------------------+-----------------------+
  </code></pre>
  
  <p>here I have price related to only <code>1</code> and <code>3</code> product so I only want those products based on queryset that i only want to filter based on specific date_of_collection.</p>
  
  <p>I have tried the following queryset: </p>
  
  <pre><code>collection_month = Collection.objects.filter(date_of_collection__month=2)
  product = Product.objects.filter(collection_id__in=collection_month).exclude(price_set__price=None)
  </code></pre>
  
  <p>is it the way I do or some next way.. it gives sometimes bad result. How do I do it.</p>