title: How do I query objects of a ManyToManyField?(without through)
body: <p>The given below are the models for a retail store.</p>
  
  <pre><code>class Rack(models.Model):
      name = models.CharField(max_length=128)
      number = models.PositiveSmallIntegerField()
      categories = models.ManyToManyField(Category)
  
  
  class Category(models.Model):
      name = models.CharField(max_length=128)
      code = models.CharField(max_length=3)
  
  
  class Product(models.Model):
      title = models.CharField(max_length=255)
      in_stock = models.BooleanField(default=False)
      categories = models.ManyToManyField(Category)
  </code></pre>
  
  <p>Rack : the rack where the products are stocked.
  Category : the Category of the product. 
  Product : the product</p>
  
  <p>A rack can have multiple categories and same category can be on multiple racks.
  for ease of managing, I prefer selecting categories on a rack at admin, so prefered this design.</p>
  
  <p>If given a rack, say No.1, How do I query the products on the given rack?</p>
  
  <pre><code>&gt;&gt; Rack.objects.get(number=1).categories.all()
  
  [&lt;Category: Fruits&gt;, &lt;Category: Vegetables&gt;]
  </code></pre>
  
  <p>I don't want to iterate this query set, but to make a query to return the objects.</p>
  
  <p>my question is, How do I query the objects on a rack <strong><em>as optimized as possible</em></strong>? </p>
  
  <p>so that the query must return a list of objects.</p>
  
  <pre><code>&gt;&gt; Rack.objects.filter( * code here to get the objects in the rack 1 * ) must returns the objects on the rack 1
  [&lt;Product: Apple&gt;, &lt;Product: Orange&gt;, &lt;Product: Cucumber&gt;, &lt;Product: Carrot&gt;, &lt;Product: Green Chillie&gt;, &lt;Product: Onion&gt;, &lt;Product: Grapes&gt; ]
  </code></pre>
  
  <p>Thanks</p>