Making a Custom Django User Model Tutorial
Table of Contents
- Understanding the Django User model
- Django User fields
- Do I need a custom Django User model?
- Application-specific data
- Additional / different authentication data
- Why do it anyway?
- Tutorial: Defining the custom model
- The model in action
- Referencing the User model
- What’s next?
- Key takeaways
Understanding the Django User model
The Django User model is at the center of Django’s authentication system. It is the mechanism for identifying the users of your web application.
A user will log in by providing their username and password. Then (depending on your authentication backend) the identity of that user is preserved across requests either through a session, a token, or some other mechanism.
When a request is made to your web application, Django loads an instance of the User model that represents (and identifies) the user of your web application.
Django User fields
All the fields on the built-in Django User model are used for authenticating the user, communicating with the user, and understanding what the user is authorized to access.
Authentication
usernamepasswordlast_logindate_joined
Communication
first_namelast_nameemail
Authorization
groupsuser_permissionsis_staffis_activeis_superuser
Do I need a custom Django User model?
The short answer is: No, but use one anyway.
Back to Top