Created
January 30, 2024 11:52
-
-
Save madewulf/1718513dca6bf8e07625feab66d04c1a to your computer and use it in GitHub Desktop.
Remove permission to a set of users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from iaso.models import * | |
from django.contrib.auth.models import Permission | |
permission = Permission.objects.get(codename="iaso_completeness") | |
acc = Account.objects.get(id=20) | |
profiles = Profile.objects.filter(account=acc).filter(user__user_permissions=permission) | |
c = 0 | |
print("permission", permission) | |
for profile in profiles: | |
print(profile) | |
profile.user.user_permissions.remove(permission) | |
c+=1 | |
print(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment