def wait_for_db_object(database_model_to_wait, model_field_to_get, model_value_to_get, timeout):
    counter = 0
    while counter < timeout:
        try:
            if model_field_to_get == "id":
                database_model_to_wait.objects.get(pk=model_value_to_get)
            elif model_field_to_get == "name":
                database_model_to_wait.objects.get(name=model_value_to_get)
            else:
                return False
            return True
        except database_model_to_wait.DoesNotExist:
            time.sleep(1)
            counter += 1
    return False