ModelName(django.contrib.auth.models.User) vs ModelName(models.Model)
- by amr.negm
I am developing a django project. I created some apps, some of those are related to User model, for instance, I have a feeds app that handles user feeds, and another app that deals with extra user data like age, contacts, and friends. for each of these, I created a table that should be connected to the User model, which I using for storing and authenticating users.
I found two ways to deal with this issue. One, is through extending User model to be like this:
ModelName(User):
friends = models.ManyToMany('self')
.....
Two, is through adding a foreign key to the new table like this:
ModelName(models.Model):
user = models.ForeignKey(User, unique=True)
friends = friends = models.ManyToMany('self')
......
I can't decide which to use in which case. in other words, what are the core differences between both?