[Answer]-Django, related_name, foreign key

1👍

As you have a ManyToManyField, you first need to create the Follows object (save it), so that it has a primary key in order for the many-to-many relationship to work. In addition, you need to use the ManyToManyManager to add items to the relationship.

In short, you need to do this:

f = Followers()
f.save()
f.user.add(u1)
f.follower.add(u2)
f.save()

Leave a comment