Custom User model or User Profile model with one to one relationship to the user model

I am a newbie to web developmnet. I'm using django and lately I have been realy confused and undecided on wether I should use a Custom user model with additional fields I need or create a seperate User profile model with one to one relationship with the user model. What is the best practice?. In which ever case is best I would like to aslo add the fields like 'followers', 'following', 'likes', 'connections' and users should be able to easily edit some details on their accounts after creating, which method is the best?

I would suggest you go for a Profile model. Depending on your requirements, make a little research, if Django's AbstractUser class has all the fields you want, Use that, it will allow you to add more fields as well as you continue to build and it's a good practice. But if AbstractUser has more fields than required, use Django's AbstractBaseUser to specify only the fields you want.

Then create a Profile model with the details you listed above, "likes", "connections", "followers", "following," and you can keep on adding more if you like. Use the models.OneToOneField to specify that a user model can have just one Profile model.

This should make everything a bit easier for you.

Back to Top