A OneToOneField creates a one-to-one database relationship: each object can relate to at most one object on the other side. It is especially useful for attaching custom profile data to Django’s User account. section 6.2.1
Use a OneToOneField when a single related object must match a single account or record:
- Store musician-specific data in a separate profile model linked to one User object. section 6.2.1
- Apply the same relationship restriction outside user profiles whenever a database foreign key must allow only one related object. section 6.2.1
- Choose the profile approach early when keeping Django’s User credentials, because switching later can require custom migrations and data cleanup. section 6.2.1
A musician profile
A Musician ORM object can hold custom musician data while a separate profile object connects it to one Django User account. The User supplies account and credential behavior; the profile supplies application-specific fields. section 6.2.1
Figure 6.2 User profiles vs. replacing the User ORM object for user data storage
Compare storing custom fields in a profile linked with OneToOneField against replacing Django’s User object entirely. section 6.2.1
