Concise question:
What are the advantages and disadvantages of Modeling a many-to-many relationship in Django (1.5) on an external table without using the through parameter?
Details:
Say, I have a custom User model UserProfile and I want to define a m2m relation to the same model, for example to implement a following relationship. I can define an external table (model) like so:
class Relationship(models.Model):
"""Relationship model"""
from_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='from_users')
to_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='to_users')
created = models.DateTimeField(auto_now_add=True)
is_blocked = models.BooleanField(default=False)
objects = RelationshipManager()
In this case should I add a m2m field to the UserProfile model as showed below ? If yes, why? I could handle all the relationships between users only using the Relationship model, isn't it?
class UserProfile(AbstractBaseUser, PermissionsMixin):
user_following = models.ManyToManyField('self', through=Relationship, symmetrical=False, related_name='followed')