When I try to print errors from a form, getting very strange output here is my code in the template (If you are curious about CSS, use Bootstrap 3),
{% if form.is_valid and form.is_bound%} and lieutenant; Div class = "row" & gt; & Lt; Div class = "col col-lg-10 col-offset-1 text-center" & gt; & Lt; Div class = "alert alert-danger" & gt; & Lt; Button type = "button" class = "off" data-discarded = "warning" & gt; And;; & Lt; / Button & gt; For error in {% Field in form}%} {% error%} & lt; Strong> {{Field.label}} & lt; / Strong>: {{error}} & lt; Br> {% Endfor%} {% endfor%} & lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; {% Endif%} All other errors are fixed, except that when I enter the wrong password, then I get an output like this,
Password: Password: Password: Password: Password: Password: r Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Password: Pa Word: Password: Password: T Password: Password: Password: Password: Password: G Password: Password: I Password: N Password :. If you look closely, then this is a sentence that says "wrong password, please try again." Except each line is getting its line
What's going on here?
For further reference, I see how I am reporting error messages in view,
form.errors ['email'] = 'Email Not found, please try again. 'Form.errors [' password '] =' Incorrect password, please try again. ' Many thanks !!
I think the problem is that the error runs through the loop string, which makes sense Because you define it as the string . form.errors ['password'] = 'Incorrect password, please try again.' Try wrapping it in a list:
form.errors ['password'] = ['Incorrect password, please try again.'] < / Code> This can also happen with email.
Hope it helps!
No comments:
Post a Comment