How To Implement Followers/following In Django
I want to implement the followers/following feature in my Django application. I've an UserProfile class for every User (django.contrib.auth.User): class UserProfile(models.Model):
Solution 1:
Set symmetrical to False in your Many2Many relation:
follows = models.ManyToManyField('self', related_name='follows', symmetrical=False)
Solution 2:
In addition to mouad's answer, may I suggest choosing a different *related_name*: If Mark follows John, then Mark is one of John's followers, right?
Post a Comment for "How To Implement Followers/following In Django"