form.has_errors tag not working
Posted
by
John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2011-01-06T12:12:47Z
Indexed on
2011/01/06
14:54 UTC
Read the original article
Hit count: 122
Hello,
Im using Django 1.2.3. I have login functionality in my site using django.contrib.auth.views.login
. The user is able to login after entering correct username and password. But, form.has_errors
is not working i.e. if the login credentials entered are incorrect i dont see the error message. My login.html in templates/registration is as follows :
<html>
<head>
<title>Login</title>
</head>
<body>
<h1>User Login</h1>
{% if form.has_errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
<form method="post" action=".">
{% csrf_token %}
<p><label for="id_username">Username:</label> {{ form.username }}</p>
<p><label for="id_password">Password:</label> {{ form.password }}</p>
<input type="hidden" name="next" value="/" />
<input type="submit" value="login" />
</form>
</body>
</html>
Any way to fix this problem?
Please Help Thank You.
© Stack Overflow or respective owner