def get_object_or_None(klass, *args, **kwargs):
    queryset = _get_queryset(klass)
    try:
        return queryset.get(*args, **kwargs)
    except queryset.model.DoesNotExist:
        return None
Uses get() to return an object or None if the object does not exist.
dataset/ETHPy150Open skorokithakis/django-annoying/annoying/functions.py/get_object_or_None