title: What does Django return if no objects are found? And why do I get a DoesNotExist
body: <p>I have a MySQL table in which I have Django register that a certain user is 'connected' to a unit. For this I have to check if the unit is allready connected to some other user. (model: AppUnitSession)</p>
  
  <p>So in my function I get three objects (models) as input (user, usersession, vehicle)</p>
  
  <p>The problem I have is that my query for the AppUnitSession fails with a</p>
  
  <pre><code>Exception Type: DoesNotExist 
  Exception Value: AppUnitSession matching query does not exist. 
  </code></pre>
  
  <p>This error occurs on the first line of this code:</p>
  
  <pre><code>sessions = AppUnitSession.objects.get(gps_unit_id=vehicle.gps_unit_id)
  sessions = sessions.exclude(validation_date__isnull=True)
  sessions = sessions.exclude(user_session_id=usersession.user_session_id)
  </code></pre>
  
  <p>from the call stack I can see that value for the vehicle.gps_unit_id is set:</p>
  
  <pre><code>{'gps_unit_id': 775L}
  </code></pre>
  
  <p>There are NO records in the AppUnitSession table that match this! all records in this table have gps_units_id = NULL (ea, the unit is available and the user can continue and after this there will be a record with the gps_unit_id set. If there are sessions found, I need do some more work.</p>
  
  <p>For the start I don't want the error. But also I want something I can iterate over or check it's length (>1) do some more checks.</p>
  
  <p>I'm a bit stuck on this one, so help and suggestions are welcome.</p>