I believe default permissions created are: add_*, change_* and delete_*.
And the format for a permission would be something like: *app_name*.add_*
model_name*

So what happens when you try:

user.has_perm('structures.add_post')
user.has_perm('structures.change_post')

If you are registering your own permissions it should be done like the docs
say:
https://docs.djangoproject.com/en/dev/topics/auth/#custom-permissions


On Wed, Nov 14, 2012 at 10:40 AM, Brehnen Wong <breh...@gmail.com> wrote:

> When I do user.has_perm(), I get FALSE, but I have added permissions to
> user manually with user.user_permissions.add(51) on the django
> console/shell, and I even show all the permissions
> with user.user_permissions.all().  (Also, if i
> use user.has_perm('sdlfjksdf'), it returns FALSE rather than an error
> saying that that permission does not exist, but that is another "issue").
>  user is active
>
> DJANGO SHELL/CONSOLE
> >>> user.has_perm('structures.edit_post')
> False
> >>> user.has_perm('structures.create_post')
> False
> >>> user.user_permissions.all()
> [<Permission: auth | group | Can add group>, <Permission: auth |
> permission | Can add permission>, <Permission: auth | permission | Can
> change permission>, <Permission: auth | permission | Can delete
> permission>, <Permission: structures | post | Can create new post>,
> <Permission: structures | post | Can edit all users' posts>]
>
> MYSQL: auth_permission
> ...
> | 50 | Can delete post                              |              13 |
> delete_post            |
> | 51 | Can create new post                          |              13 |
> create_post            |
> | 52 | Can edit all users' posts                    |              13 |
> edit_post              |
>
> +----+----------------------------------------------+-----------------+------------------------+
>
> MYSQL: django_content_type
> +----+--------------+--------------+--------------+
> | id | name         | app_label    | model        |
> +----+--------------+--------------+--------------+
> |  1 | permission   | auth         | permission   |
> |  2 | group        | auth         | group        |
> |  3 | user         | auth         | user         |
> |  4 | content type | contenttypes | contenttype  |
> |  5 | session      | sessions     | session      |
> |  6 | site         | sites        | site         |
> |  9 | category     | structures   | category     |
> | 10 | thread       | structures   | thread       |
> | 11 | bookmark     | structures   | bookmark     |
> | 12 | subscription | structures   | subscription |
> | 13 | post         | structures   | post         |
> +----+--------------+--------------+--------------+
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/BEYgkvLkouEJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to