Monday, December 15, 2008

errors and has_errors

There is a slight difference between Django 1.0 and 0.95.When we use user authentication in Django,and we create pass a form object to login.html template for example.
<div style="margin-left: 40px;"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Django Bookmarks - User Login</title>
<h1>User Login</h1>
{%if form.has_errors%}
<p>Your username and password didn't match.
Please try again.</p>
<form method="post" action=".">
<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">

In version 0.95,it's work fine.but if you run it under the version 1.0,you can't see the error message when you login-failing.The question is in Django 1.0,the attribute of form object is errors instead of change the attribute it'll work well.


Bernt Ivar said...

Thanks a lot!

cardeo said...

Thanks! the book I'm working off is from the old version, your tip fixed it for me

BillyIdiot(gethoper) said...

Thanks a lot!!!