How to Check a User's Password in Django. In this article, we show how to check a user's password in Django. Django does have a login function that allows a user to log in, once the username and password are supplied. However, checking the password alone may be important, such as if you are creating a 'Change Password' page for your website.
Home > Articles > Web Design & Development > PHP/MySQL/Scripting
␡- Creating a New User
Django Add User
This chapter is from the book
This chapter is from the book
Creating a New User
Django Manually Create User With Password Hash
Editing fields in a database as we did in the previous topic is fine if the object you want to work with already exists. But what if it doesn't? What if you want to create a new object in the database yourself, from code?
For example, how would you create a new User object? For that, you can use the create_user method and then save the new User object, like this:
Here, we'll create a new user and then get the user's email address to confirm that the new user exists.
To create a new user:
- Using a text editor, edit chapter4favoritesviews.py, adding the code shown in Listing 4.19.
Listing 4.19. The edited views.py file.
- Add the code to actually access the new user's email address and display it, shown in Listing 4.20.
Listing 4.20. The completed views.py file.
g - Save views.py.
- Open a command prompt and navigate to the chapter4 directory:
- Run the development server:
- Navigate your browser to http://localhost:8000.
You should see the Web page shown in Figure 4.8.
Figure 4.8 Displaying the new user's email address.
Related Resources
Django Manually Create User With Password On Iphone
- Book $31.99
Django Manually Create User With Password Windows 10
- eBook (Watermarked) $25.59
- eBook (Watermarked) $47.99