Reputation: 1
How i can check permission to object for user with global permission ?
joe = User.objects.get(username="joe")
assign_perm('parse.show_company', joe) # assign global permission
company = Company.objects.get(id=id)
joe.has_perm('parse.show_company', company ) # check permission for object, return False
Upvotes: 0
Views: 405
Reputation: 1174
This is an open issue with permission checker in django guardian app. You can find it on github.
https://github.com/django-guardian/django-guardian/issues/294
You can also check global permission for the object with user like below:
from guardian.shortcuts import get_objects_for_user
if company in get_objects_for_user(company, 'parse.show_company'):
# do your stuff
I hope this will help you.
Upvotes: 1