37👍
✅
See documentation https://docs.djangoproject.com/en/stable/topics/auth/#methods
g.user_set.remove(your_user)
18👍
The simplest method to clear all user groups from the user object is
user_obj.groups.clear()
- [Django]-List_display – boolean icons for methods
- [Django]-Django: TypeError: 'tuple' object is not callable
- [Django]-How to override the verbose name of a superclass model field in django
16👍
To remove a specific Group:
group = Group.objects.get(name='groupname')
user.groups.remove(group)
- [Django]-How to debug Django commands in PyCharm
- [Django]-Skip system checks on Django server in DEBUG mode in Pycharm
- [Django]-Django migrations – workflow with multiple dev branches
Source:stackexchange.com