22.3 Custom User
Creating a Profile
model is great when we need to add information, but it becomes woefully unhelpful if we want to change or remove information. I am not a fan of the fact that our current implementation uses both a username
and an email
field on the User
model. If we want to use only the email
field, we must change the User
model itself.
The User
model is actually a very thin model that inherits from AbstractUser
, where most of the user fields are defined. However, this class in turn inherits from AbstractBaseUser
and PermissionsMixin
. The AbstractBaseUser
defines the heart of the User
model, supplying the password
and last_login
field as well as the methods to interact with the password
field. The PermissionsMixin
defines ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.