I have an admin site , I want to edit and add roles to it.
I can get all the permissions using the POST
method by calling every name but I have many permissions and groups .
But by using that I can only save one group at a time.
Is there a way to get the permissions separated by groups when the save button was clicked?
For example:
{'Super Admin':['permision1','permision2'], 'Admin':['permision1'], 'Subscription Manager':['permision2]}
You can fetch the items with the permissions with:
from django.contrib.auth.models import Group
{
group.name: [perm.name for perm in group.permissions.all()]
for group in Group.objects.prefetch_related('permissions')
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.