- Django 2 by Example
- Antonio Melé
- 257字
- 2021-06-25 21:19:10
Using Django authentication views
Django includes several forms and views in the authentication framework that you can use straight away. The login view you have created is a good exercise to understand the process of user authentication in Django. However, you can use the default Django authentication views in most cases.
Django provides the following class-based views to deal with authentication. All of them are located in django.contrib.auth.views:
- LoginView: Handles a login form and logs in a user
- LogoutView: Logs out a user
Django provides the following views to handle password changes:
- PasswordChangeView: Handles a form to change the user password
- PasswordChangeDoneView: The success view the user is redirected to after a successful password change
Django also includes the following views to allow users to reset their password:
- PasswordResetView: Allows users to reset their password. It generates a one-time use link with a token and sends it to the user's email account.
- PasswordResetDoneView: Tells users that an email—including a link to reset their password—has been sent to them.
- PasswordResetConfirmView: Allows users to set a new password.
- PasswordResetCompleteView: The success view the user is redirected to after successfully resetting the password.
The views listed in the preceding list can save you a lot of time when creating a website with user accounts. The views use default values that you can override, such as the location of the template to be rendered, or the form to be used by the view.
You can get more information about the built-in authentication views at https://docs.djangoproject.com/en/2.0/topics/auth/default/#all-authentication-views.
- Application Development with Qt Creator(Second Edition)
- 連接未來:從古登堡到谷歌的網絡革命
- MERN Quick Start Guide
- 物聯網智慧安監技術
- GPS/GNSS原理與應用(第3版)
- OpenLayers Cookbook
- 新一代物聯網架構技術:分層算力網絡
- 網絡安全應急響應技術實戰
- 端到端QoS網絡設計
- Getting Started with Memcached
- 物聯網工程概論
- Selenium WebDriver 3 Practical Guide
- 數字王國里的虛擬人:技術、商業與法律解讀
- Telerik WPF Controls Tutorial
- 物聯網系統設計