Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#9414 closed (fixed)

Documentation on has_perm and the permission_required decorator is confusing

Reported by: wallenfe Owned by: jacob
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The documentation on using has_perm and permission_required is confusing in that it does not define how the permission string that is passed to those functions is defined.

The documentation should mention that the string is:
ApplicationName.PermissionName.

Since Permissions are defined on models, my first inclination was to try: ModelName.PermissionName

This is the documentation page I am referring to:
http://docs.djangoproject.com/en/dev/topics/auth/#topics-auth

And an example of the permission string being used, but without an explanation.
"
def my_view(request):

if not (request.user.is_authenticated() and request.user.has_perm('polls.can_vote')):

"

Attachments (1)

9414.diff (1.7 KB) - added by timo 6 years ago.
clarify has_perm arguments permissions

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 years ago by jacob

  • Owner changed from nobody to jacob
  • Status changed from new to assigned

comment:3 Changed 6 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [10371]) Fixed a whole bunch of small docs typos, errors, and ommissions.

Fixes #8358, #8396, #8724, #9043, #9128, #9247, #9267, #9267, #9375, #9409, #9414, #9416, #9446, #9454, #9464, #9503, #9518, #9533, #9657, #9658, #9683, #9733, #9771, #9835, #9836, #9837, #9897, #9906, #9912, #9945, #9986, #9992, #10055, #10084, #10091, #10145, #10245, #10257, #10309, #10358, #10359, #10424, #10426, #10508, #10531, #10551, #10635, #10637, #10656, #10658, #10690, #10699, #19528.

Thanks to all the respective authors of those tickets.

comment:4 Changed 6 years ago by anonymous

  • Resolution fixed deleted
  • Status changed from closed to reopened

The documentation is still wrong: http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.models.User.has_perm

It says "<application name>.<lowercased model name>" repeatedly (at least twice) in the documentation, when in fact it should be "<application name>.<lowercased permission codename>"

Changed 6 years ago by timo

clarify has_perm arguments permissions

comment:5 Changed 6 years ago by timo

  • Has patch set
  • milestone 1.1 deleted
  • Triage Stage changed from Accepted to Ready for checkin
  • Version changed from 1.0 to SVN

comment:6 Changed 6 years ago by russellm

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [11547]) Fixed #9414 -- Clarified the documentation on the permission decorators. Thanks to timo for the patch.

comment:7 Changed 6 years ago by russellm

(In [11569]) [1.1.X] Fixed #9414 -- Clarified the documentation on the permission decorators. Thanks to timo for the patch.

Merge of r11547 from trunk.

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