Is it possible to catch the MultipleObjectsReturned error in Django?
I am doing a search query, and if there are several objects, I want the first in the list to be accepted, so I tried this:
try: Location.objects.get(name='Paul') except MultipleObjectsReturned: Location.objects.get(name='Paul')[0]
However, it exists in the doc , although
global variable MultipleObjectsReturned does not exist
source share