【发布时间】:2011-01-06 12:12:47
【问题描述】:
我正在使用 Django 1.2.3。我在我的网站中使用django.contrib.auth.views.login 登录功能。用户输入正确的用户名和密码后即可登录。但是,form.has_errors 不起作用,即如果输入的登录凭据不正确,我看不到错误消息。我在模板/注册中的 login.html 如下:
<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>
有什么办法可以解决这个问题?
请帮忙 谢谢。
【问题讨论】: