A custom user model replaces Django’s built-in User model when an application needs different account data or credential behavior. For example, it can use an email address instead of a username for login. section 6.2.1
Choose the account-storage approach early:
- Use a profile model when the built-in User credentials are sufficient. Connect the profile to User with a OneToOneField, which permits one profile per account and one account per profile. section 6.2.1
- Replace User with a custom model when account data or credential behavior must change. Replacing it also requires replacing the associated user manager. section 6.2.1
- Treat the choice as an early design decision: Django uses one account mechanism at a time, and changing mechanisms later can require custom migrations and data cleanup. section 6.2.1
Email-based login
A musician account may need an email address as its login credential rather than a username. A profile model cannot change the built-in credential mechanism; a custom user model can. section 6.2.1
Figure 6.2 User profiles vs. replacing the User ORM object for user data storage
Compare the objects and database relationships used by a profile model and a replacement User model. section 6.2.1
