title: Django: Get an object form the DB, or 'None' if nothing matches
body: <p>Is there any Django function which will let me get an object form the database, or None if nothing matches?</p>
  
  <p>Right now I'm using something like:</p>
  
  <pre><code>foo = Foo.objects.filter(bar=baz)
  foo = len(foo) &gt; 0 and foo.get() or None
  </code></pre>
  
  <p>But that's not very clear, and it's messy to have everywhere.</p>