django_baseline/models.py
def get_object_or_none(qs, *args, **kwargs):
    """
    Try to retrieve a model, and return None if
    it is not found.
    Useful if you do not want to bother with the try/except block.
    """

    try:
        return qs.get(*args, **kwargs)
    except models.ObjectDoesNotExist:
        return None
def get_object_or_none(qs, *args, **kwargs):
    """
    Try to retrieve a model, and return None if
    it is not found.
    Useful if you do not want to bother with the try/except block.
    """

    try:
        return qs.get(*args, **kwargs)
    except models.ObjectDoesNotExist:
        return None
Try to retrieve a model, and return None if
    it is not found.
    Useful if you do not want to bother with the try/except block.