How to handle “matching query does not exist” when getting an object
When I want to select objects with a get() function like personalProfile = World.objects.get(ID=personID) If get function doesn't return find a value, a "matching query does not exist." error occurs. If I don't need this error, I'll use try and except function try: personalProfile = World.objects.get(ID=personID) except: pass But I think this is not the best way since I use except: pass Please recommend some idea or code sample to fight with this issue That depends on what you want to do if it doesn't exist.. Theres get_object_or_404 : Calls get() on a given model manager, but it raises