Django: When extending User, better to use OneToOneField(User) or ForeignKey(User, unique=True)?

The only real reason given in the article is that it can be set up so that the admin page for User will show both the fields in User and UserProfile. This can be replicated with a OneToOneField with a little elbow grease, so unless you’re addicted to showing it in the admin page with no work at the cost of a bit of clarity (“We can create multiple profiles per user?! Oh no, wait, it’s set unique.”) I’d use OneToOneField.

Leave a Comment