Hey all,
I'm trying to use Django's permission functionalities but having some
trouble.
I've created a custom permission in one of my models with this code:
class Meta:
permissions = (
("actions_for_both_user_type", "General permission for both
user types"),
("actions_for_managers", "managers general permission"),
)
I synced the DB and I can see the permissions in auth_permission table.
I entered the Django admin panel and chose a test user and gave him the 2
new permissions.
I've added a view that should be served only for a user with one of these
permissions with this header:
@permission_required('campaign.actions_for_managers')
After login in with the user with the permissions I still can't get into
the view.
If I take the permission_required head off and print these three lines
print request.user
print request.user.has_perm('campaign.actions_for_managers')
print request.user.user_permissions.all()
I'll see that I get the correct logged in user.
False for the second line (has_perm)
and for the third line I get this result:
[<Permission: campaign | campaign | General permission for both user types>,
<Permission: campaign | campaign | managers general permission>]
I'm not sure what I'm doing wrong. It seems like the user does have the
permission but the "had_perm" isn't working..
Please help.
Best
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/437f8490-d71a-4990-9121-f20465576576%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.