title: Retrieving a Django model with only a subset of related objects
body: <p>I'm attempting to retrieve a specific Django model with only a subset of its related objects that match a certain criteria. For example, I want to get a specific <code>Restaurant</code>, and return all of the <code>Pizza</code>s served at this restaurant that are vegetarian.</p>
  
  <p>For example, if I have a <code>Restaurant</code> named <code>Papa's Pizza</code> that serves some pizza.</p>
  
  <p>Let's say I have a <code>Pizza</code> model like this:</p>
  
  <pre><code>class Pizza(models.Model):
     ...
     type = models.CharField(...)
     restaurant = models.ForeignKey('Restaurant', related_name='pizzas_offered')
     ...
  </code></pre>
  
  <p>And <code>Papa's Pizza</code> offers the following <code>Pizza</code>s:</p>
  
  <ul>
  <li><code>Margherita</code> (<code>type='vegetarian'</code>)</li>
  <li><code>Pepperoni</code> (<code>type='carnivore'</code>)</li>
  <li><code>Pineapple-Only</code> (<code>type='vegetarian</code>)</li>
  </ul>
  
  <p>I'd like to retrieve the <code>Papa's Pizza</code> model with only the <code>Margherita</code> and <code>Pineapple-Only</code> pizzas in the <code>pizzas_offered</code> field.</p>
  
  <p>How would I go about accomplishing this?</p>
  
  <p>If it helps at all, I'm also using <a href="http://django-rest-framework.org/" rel="nofollow noreferrer">Django Rest Framework</a>, so if you have any experience with that and the functionality might exist in a <a href="http://www.django-rest-framework.org/api-guide/serializers/" rel="nofollow noreferrer"><code>Serializer</code></a> rather than in the model, that will work too.</p>
  
  <p>Thank you very much!</p>