[Django]-User.groups.add(group) or group.user_set.add(user), Which is better and why ? or difference between them

6👍

They do the exact same thing.

A many-to-many relation consists of an intermediate table with a foreign key to both models. user.groups.add(group) will create an entry in that table where the foreign keys point to the user and group instances. The same happens with group.user_set.add(user).

👤knbk

Leave a comment