The User Management section of the Django blog site (using its own django.contrib.auth) 1. Registration section
Project tools: Python 2.7.11 Django 1.10.2 Bootstrap 3.3.0 ide:eclipse Pydev
1. Because Django comes with Auth, you only need to write the login URL and template.
URLs common in the previous article
The template code is provided as a reference only:
Login
1 {% extends "account_base.html"%}2 3 {% block title%} User login {% endblock%}4 5 {% block content%}6 <H1>Login</H1>7 {% if form.errors%}8 <P>The user name and password are incorrect, please try again</P>9 {% Else%}Ten <P>Please log in. If you do not have an account, please<ahref= "{% url"register "%}">Registered</a></P> One {% endif%} A - <Divclass= "Login-form"> - <formAction= "{% url"Login "%}" method= "POST"> the {{form.as_p}} - {% Csrf_token%} - <inputtype= "hidden"name= "Next"value= "{{next}}" /> - <P><inputtype= "Submit"value= "Login"></P> + </form> - <P><ahref= "{% url"password_reset "%}">Forgot your password?</a></P> + </Div> A at{% Endblock%}
Logout
1 {% extends "account_base.html"%}2 3 {% block title%} logoff {% Endblock%}4 5 {% block content%}6 <H1>Cancellation</H1>7 <P>The logoff was successful. You can again<ahref= "{% url"Login "%}">Login</a>.</P>8{% Endblock%}
Change Password:
1 {% extends "account_base.html"%}2 3 {% block title%} Modify password {% Endblock%}4 5 {% block content%}6 <H1>Change Password</H1>7 <P>Fill in the form below, change the password</P>8 <formAction="."Method= "POST">9 {{form.as_p}}Ten <P><inputtype= "Submit"value= "Modify"></P> One {% Csrf_token%} A </form> -{% Endblock%}
Note that Csrf_token needs to be considered in a unified and easy-to-test project, commenting out the Csrf_token middleware in its initial setup. Post-perfection
Other password_reset_form and other parts need to be self-improvement, not listed.
The User Management section of the Django blogging site (with its own django.contrib.auth) 2. Login log out and user information management