Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize the functions of user login and exit and personal data in Django

Shulou Source: shulou.com Published: 2022-06-01 15:04:32 10月01日 Update

This article shows you how to achieve user login and login and profile functions in Django. The content is concise and easy to understand, and it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Today, we improve the user's login and logout functions, add the user's profile function, and the verification menu can only be accessed when the user is logged in. Let's start with:

First, modify django_project\ django_project\ urls.py to add three url forwarding rules: personal information, login and exit:

Create a new login.html login page under django_project\ users\ templates\ users:

Create a new logout.html login page under django_project\ users\ templates\ users:

Create a new profile.html profile page under django_project\ users\ templates\ users:

Modify django_project\ users\ views.py to add profile information method:

Change django_project\ blog\ templates\ blog\ base.html, and add the verification of login information in the navigation section to display the relevant navigation:

Modify django_project/django_project\ settings.py to specify the jump address after successful login, and the login address:

We run the python manage.py runserver startup project under the django_project folder, visit http://127.0.0.1:8000/login to access the login page and enter information to submit:

After logging in successfully, the personal information and exit link are displayed in the upper right corner of the navigation, and click on the personal information:

Click the exit link:

The above is how to achieve user login and login and profile functions in Django. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Login personal information user profile profile function page navigation success content address skill knowledge link verification conciseness and then succinct three Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Information vpn Apple Linux