Checks if a field / value pair exists in database
    and continues generating values until it finds
    a one that does not exist

    func is the function that generates values and
    params is the parameters that function takes

def get_db_distinct(queryset, field, func, **params):
    """
    Checks if a field / value pair exists in database
    and continues generating values until it finds
    a one that does not exist

    func is the function that generates values and
    params is the parameters that function takes
    """
    while True:
        try:
            value = func(**params)
            queryset.get(**{field: value})
        except ObjectDoesNotExist:
            break
    return value