I have proposal for new method get_object_or_none it’s like method get_object_or_404 . this method return object if exist other wise raise error
i want to design function with return object if exist other wise return None
You can easily add this as a manager method.
However, I’ve found that in most cases, it really doesn’t improve the code. You usually still end up having to have an if
statement to check whether or not None
was returned. I don’t see where that’s necessarily better than a try / except
block around the get
or using the get_object_or_404
function.