The User Management section of the Django blogging site (with its own django.contrib.auth) 2. Login log out and user information management

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.