title: How to handle an exception in Django moving from get() to filter()
body: <p>original code with get()</p>
  
  <pre><code>    try:
          record = Record.objects.get(name__iexact=record_name)
      except Record.DoesNotExist:
          logging.debug("Error: Record does not exist")
          return Response({"Error": "Record does not exist"}, status=status.HTTP_404_NOT_FOUND)
  </code></pre>
  
  <p>This query can return more than one record, so I am going to switch to this</p>
  
  <pre><code>    try:
          record = Record.objects.filter(name__iexact=record_name)[0]
      except Record.DoesNotExist:
          logging.debug("Error: Record does not exist")
          return Response({"Error": "Record does not exist"}, status=status.HTTP_404_NOT_FOUND)
  </code></pre>
  
  <p>However, then my exception handling doesn't work.  How do I make my exception catch if the query returns an empty list?</p>