title: Django left outer join with filter
body: <p>I'm using Django's built-in user model and have a custom Foo object with a ForeignKey to User. I'm looking to select all User objects and all of the Foo objects that fit certain constraints, like so:</p>
  
  <pre><code>SELECT * from auth_user LEFT OUTER JOIN "foo" ON
  (auth_user.id = foo.id AND &lt;other criteria here&gt;)
  </code></pre>
  
  <p>How should I accomplish this in Django? So far I've tried:</p>
  
  <pre><code>User.objects.filter(foo__&lt;criteria&gt;)
  </code></pre>
  
  <p>but that generates SQL similar to this:</p>
  
  <pre><code>SELECT * from auth_user LEFT OUTER JOIN "foo" ON
  (auth_user.id = foo.id) WHERE &lt;other criteria here&gt;
  </code></pre>
  
  <p>and only returns User objects that have Foo objects that fit the criteria. Alternately I can select all User objects and run a query for each one, but that would be substantially less efficient.</p>