Interesting result when displaying errors for contrib.auth.forms AuthenticationForm

13 views
Skip to first unread message

Brandon Taylor

unread,
Nov 9, 2008, 12:55:31 PM11/9/08
to Django users
Hi everyone,

I'm leveraging auth and have a login form that uses contrib.auth.forms
AuthenticationForm.

When displaying non-field-specific errors, I get interesting results:

#template.html
# if form.errors
__all__
<ul class="errorlist">
<li>Please enter a correct username and password. Note that both
fields are case-sensitive.</li>
</ul>

Does anyone know how I can get rid of the __all__ ?

TIA,
Brandon

Alex Koshelev

unread,
Nov 9, 2008, 1:01:07 PM11/9/08
to django...@googlegroups.com
Please show complete template code

Brandon Taylor

unread,
Nov 9, 2008, 4:52:55 PM11/9/08
to Django users
Here you go:

<form id="login_form" action="{% url create_account_or_login %}"
method="post">
<fieldset>
<legend>Login to your Account</legend>
<ol>
<li>
{{ authentication_form.username.label_tag }}
{{ authentication_form.username }}
{{ authentication_form.username.errors }}
</li>
<li>
{{ authentication_form.password.label_tag }}
{{ authentication_form.password }}
{{ authentication_form.password.errors }}
</li>
{% if authentication_form.errors %}
<li>
{{ authentication_form.errors }}
</li>
{% endif %}
<li>
<input class="submit" type="submit" value="Login" />
</li>
</ol>
</fieldset>
</form>

On Nov 9, 12:01 pm, "Alex Koshelev" <daeva...@gmail.com> wrote:
> Please show complete template code
>

Alex Koshelev

unread,
Nov 9, 2008, 5:17:06 PM11/9/08
to django...@googlegroups.com
Oh, I see. There is `non_field_errors` form method. It only returns errors that is not associated with concrete field.

{{ authentication_form.non_field_errors }}

`errors` just holds all form errors as a dict.

Brandon Taylor

unread,
Nov 9, 2008, 5:23:25 PM11/9/08
to Django users
Ah, thanks Alex!

On Nov 9, 4:17 pm, "Alex Koshelev" <daeva...@gmail.com> wrote:
> Oh, I see. There is `non_field_errors` form method. It only returns errors
> that is not associated with concrete field.
>
> {{ authentication_form.non_field_errors }}
>
> `errors` just holds all form errors as a dict.
>
Reply all
Reply to author
Forward
0 new messages