Reputation: 1382
How to filter from auth_group_permissions table Django. actually, I don't know by which model I can filter from auth_group_permissions.
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
I only get this model from Django documentation but I don't get any from for auth_group_permissions table. please anyone helps me.
Upvotes: 0
Views: 621
Reputation: 1242
in auth group models Permission class have Many2Many relation with permissions, that's why django creates a through table called auth_group_permission table.
for your answer you can't directly do that using models, unless you are interested in changing django core code itself. if you still want to do that you can write raw sql.
though this shouldn't stop you from accessing the elements.
from django.contrib.auth.models import Group
group = Group.objects.first()
group.permissions.all()
Upvotes: 1