Due to lack of knowledge, when faced with the need to store additional information about users, I created additional UserInfo model and referenced it by foreign key to the standard User model.
I have since learned two things:
- It is recommended to have a custom user model.
- It is tricky to switch mid-project (this being the best way so far as far as I understand).
I would like to understand:
- If the fields in
UserInfoare not used for authentication, is there any reason to merge those into the user model? - What do I stand to gain by taking the time to abandon my current approach and switch to a custom user model?
If the
UserInfomodel is not required for authentication, then there's no need to create a completely customUsermodel.What you're currently doing is fine.
But instead of using
ForeignKey, useOneToOneFieldso that oneUserInfoinstance is tied to one and only oneUserinstance.This method is also shown in the documentation: https://docs.djangoproject.com/en/5.0/topics/auth/customizing/#extending-the-existing-user-model.