In Django authentication permissions, how to remove all permissions granted to a group?
Asked
Active
Viewed 3,335 times
1 Answers
9
There are separate ways to do this.
via
admin
via
database
DELETE FROM auth_group_permissions WHERE group_id=<id>;
via
shell
$ python manage.py shell
>>> from django.contrib.auth.models import Group >>> group = Group.objects.get(id=<id>) >>> group.permissions.clear()
Edit: .clear()
makes more sense than .all().delete()
, thx Ivan ;)

wfehr
- 2,185
- 10
- 21
-
3Won't `.all().delete()` remove the related *permission objects*? So that would result in the fact that the permissions no longer exists, not the permissions to that group. – Willem Van Onsem Sep 24 '19 at 11:48
-
@WillemVanOnsem yep, already corrected it as I saw the other answer. – wfehr Sep 24 '19 at 11:50
-
@WillemVanOnsem yep, thats how I ended up here. – Bradleo Jun 28 '22 at 05:45