Opened 8 years ago

Closed 8 years ago

#28156 closed Bug (invalid)

User.has_perm always returns False for a custom permission inherited from group

Reported by: Vasili Korol Owned by: nobody
Component: contrib.auth Version: 1.8
Severity: Normal Keywords: permissions
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I define a custom permission in one of my models (in application called 'tasks'):

class Task ( models.Model ) :
    ...
    class Meta :
         permissions = ( ( "Can run tasks on the local server", "run_task_locally" ), )

In the admin interface, I grant this permission to one of the auth groups.
Now, for all users, belonging to this group, user.has_perm( "tasks.run_task_locally" ) is False. If the permission is granted for each user individually (not through the group), or if it's a supersuser, then user.has_perm returns True.

I do not observe this problem with standard model permissions like appname.add_modelname or appname.change_modelname.

Running Django 1.8.18 on Python 3.4.3 using default authentication backend.

Change History (2)

comment:1 by Vasili Korol, 8 years ago

Type: UncategorizedBug

comment:2 by Tim Graham, 8 years ago

Resolution: invalid
Status: newclosed

You put the permission's name first in the tuple rather than the codename. It should be: permissions = ( ("run_task_locally", "Can run tasks on the local server"), )

Note: See TracTickets for help on using tickets.
Back to Top