def _get_viewname(instance, action):
    """
    Return the appropriate viewname for adding, editing, or deleting an instance.
    """

    # Validate action
    assert action in ("add", "edit", "delete")
    viewname = "{}:{}_{}".format(instance._meta.app_label, instance._meta.model_name, action)

    return viewname