A function for doing this more safely is `get_object_or_None`, which returns `None` if the object isn't found, otherwise the object itself.  A similar function is `get_object_or_404`, which returns a `Http404` response if the object isn't found.

Search the codebase for the proper import and usage of these functions.