I'm using the standard authentication form. It's clean method looks like this :
def clean(self):
username = self.cleaned_data.get('username')
password = self.cleaned_data.get('password')
if username and password:
self.user_cache = authenticate(username=username, password=password)
if self.user_cache is None:
raise forms.ValidationError(_("Please enter a correct username and password. Note that both fields are case-sensitive."))
elif not self.user_cache.is_active:
raise forms.ValidationError(_("This account is inactive."))
# TODO: determine whether this should move to its own method.
if self.request:
if not self.request.session.test_cookie_worked():
raise forms.ValidationError(_("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in."))
return self.cleaned_data
My login form :
<form method="post" action="{% url django.contrib.auth.views.login %}">
<table>
{% if form.errors %}
<tr class="form-errors">
<td>
<ol>
{% for error in form.errors %}
<li>{{ error }}</li>
{% endfor %}
</ol>
</td>
</tr>
{% endif %}
But instead of the validation messages I get :
if username and pass is incorrect or account is inactive : "1. __all__
"
if password is not given : "1. password
"
if username is not given : "1. username
"
if both are not given : "1. username 2. password
"
no message for incorrect username
EDIT: If I change
<td>
<ol>
{% for error in form.errors %}
<li>{{ error }}</li>
{% endfor %}
</ol>
</td>
to :
{{ form.errors }}
I receive i.e __all__ and beneath it "Account inactive"
. How to get just the message ?
Any ideas ?