I am new to Django and I am trying to create a login page.
Here (part) of my urls.py file:
urlpatterns = patterns('', (r'^$', main_page), (r'^login/$', 'django.contrib.auth.views.login'), )
And here is the template for my login page (registration / login.html):
<html> <head> <title>User Login</title> </head> <body> <h1>User Login</h1> {% if form.errors %} <p>username and password don't match.</p> {% endif %} <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" name="login" /> </form> </body> </html>
When I launch the application and go to login.html, I get the following error message:
TemplateSyntaxError at / login /
Invalid block tag: 'form.username'
I donβt understand what went wrong. As far as I know, it is assumed that the login should load this template and pass the form object. When printing, the form.username attribute should generate HTML code for the username text box. Why is this not happening?
source share