(form, wmd_prefix='', override_content=False)
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, wmd_prefix='', override_content=False):
    """
    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:
                # wmd_prefix is required when dealing with 'content' field.
                field_id = wmd_prefix if (override_content and field.name == 'content') else field.id_for_label
                errorlist.append((f'{field.name}:', error, field_id))

    except Exception as exc:
        errorlist = []
        logging.error(exc)

    context = dict(errorlist=errorlist)

    return context
def form_errors ( form , wmd_prefix = '' , override_content = False ) : try : errorlist = [ ( '' , message , '' ) for message in form . non_field_errors ( ) ] for field in form : for error in field . errors : # wmd_prefix is required when dealing with 'content' field. field_id = wmd_prefix if ( override_content and field . name == 'content' ) else field . id_for_label errorlist . append ( ( f'{field.name}:' , error , field_id ) ) except Exception as exc : errorlist = [ ] logging . error ( exc ) context = dict ( errorlist = errorlist ) return context