def get_form_errors(form):
    """Return a list of errors on the form

    `form` is already known to be invalid,
    e.g. form.is_valid() == False
    """
    all_errors = []
    all_field_errors = []
    for error in form.non_field_errors():
        all_errors.append(error)
    for field in form:
        if field.errors:
            # store the field errors as a tuple
            field_errors = (field.name, field.errors,)
            all_field_errors.append(field_errors)
    return (all_errors, all_field_errors,)