Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report