(form)
return context
Turns form errors into a data structure
Turns form errors into a data structure
Turns form errors into a data structure
def form_errors(form):
    """
    Turns form errors into a data structure
    """
    try:
        errorlist = [('', message) for message in form.non_field_errors()]

        for field in form:
            for error in field.errors:
                errorlist.append((f'{field.name}:', error))
    except Exception:
        errorlist = []

    context = dict(errorlist=errorlist)

    return context
def form_errors ( form ) : try : errorlist = [ ( '' , message ) for message in form . non_field_errors ( ) ] for field in form : for error in field . errors : errorlist . append ( ( f'{field.name}:' , error ) ) except Exception : errorlist = [ ] context = dict ( errorlist = errorlist ) return context