django many-to-many recursive relationship

Viewed 2558

I want to implement a basic social network model in django, i.e., followers and followees

class CustomUser(User):
    followers = models.ManyToManyField('self', related_name='followees',
                                       related_query_name='followee')

and above is what I define.I think this will be enough because the manytomany field provide backtrack query. Do I still need to create a followees ManyToMany filed?

And could anybody help write the function how to get the number of followers and followees, as well as followers list and followees list. I'm new to django So I'm confused about the many-to-many field

2 Answers
Related