How to handle “matching query does not exist” when getting an object
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 Http404 instead of the model’s DoesNotExist exception. get_object_or_404(World, ID=personID) Which is very close to the try except code you currently do. Otherwise theres get_or_create: personalProfile, created = World.objects.get_or_create(ID=personID) Although, If you … Read more