[Django]-Why shouldn’t I add additional profile fields directly to my django.contrib.auth.models.User table?

3👍

I can think of following reasons:

Django updates

You have to update your contrib.auth each time you update Django so you don’t break your application, and this is a maintenance nightmare. Using AUTH_PROFILE_MODEL method makes Django updates painless while it provides ability to add new information to User. This is called loose coupling i belive.

User dependant applications

3rd party application that heavily rely on User having the exact same fields will fail if you for example add fields to User model that are declared as NOT NULL or remove some that are expected to be there.

Further reading about AUTH_PROFILE_MODEL:

1👍

Short answer, it is more maintainable to use profiles. Based on my understanding what is advised against is making changes that will be removed once you update your Django version. If you modify django.contrib.auth.models.User model, then the changes will be removed once you update, or you will be responsibly for merging any changes done if any. On the other hand if the code lives in your application such as the profiles does then it’s easier to manage. Based on that if you find another method that achieves the same, or if you don’t see it as a maintenance hassle then It should not matter much one way or the other.

Leave a comment