[Answered ]-Django / better way to make follow model and get follower and following list

1👍

If you use a custom user model you can add a ManyToManyField with 'self' and your model Follow as the through model, while keeping symmetrical=False:

class User(AbstractUser):
    following = models.ManyToManyField('self', through='Follow', symmetrical=False, related_name='followers')
    ...

Now you can directly access the related models by {% for follow in user.following.all %} etc.

Leave a comment