How to implement followers/following in Django

后端 未结 2 495
北荒
北荒 2021-01-31 11:23

I want to implement the followers/following feature in my Django application.

I\'ve an UserProfile class for every User (django.contrib

相关标签:
2条回答
  • 2021-01-31 11:39

    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?

    0 讨论(0)
  • 2021-01-31 11:48

    Set symmetrical to False in your Many2Many relation:

    follows = models.ManyToManyField('self', related_name='follows', symmetrical=False)
    
    0 讨论(0)
提交回复
热议问题