Django remove user from all groups
I want to remove a user from all groups that I am assigned to. I am using the standard auth app in Django.
So far, I can delete one group at a time:
user.groups.remove(group)
but this adds a lot of sql overhead. I understand that this is a many-to-many relationship, but I cannot find which model represents many, many pictures and call the delete method from there.
I would like to execute the following query with the Django ORM:
delete from auth_user_group where user_id = 123
+3
source to share