id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 27242 Add get_object_or_none to django.shortcuts Alexey Rogachev nobody "Quite often we need to find object of certain model and return `None` if it does not exist. I suggest to add this to `django.shortcuts` similar to `get_object_or_404`: {{{#!python def get_object_or_none(klass, *args, **kwargs): queryset = _get_queryset(klass) try: return queryset.get(*args, **kwargs) except queryset.model.DoesNotExist: return None }}} Yes, we can easily create this in our own code, but maybe consider to add this to the core?" New feature closed Core (Other) dev Normal duplicate object, model, shortcut Unreviewed 0 0 0 0 0 0