How do I define default permissions for users in Django Guardian?
Asked Answered
S

1

4

When I create a user in Django, he has no permissions:

In [7]: u = User.objects.create(username='aoeu')
In [12]: u.user_permissions.all()
Out[12]: []

I want some permissions to be set by default (say, 'api.add_item'), and I use Django Guardian. Is this possible to do in a declarative way, eg. without writing a post_save signal?

Sarmatia answered 7/9, 2012 at 6:35 Comment(0)
S
0

No, it is not possible. Check django.contrib.auth code to ensure

Sanitary answered 7/9, 2012 at 6:44 Comment(1)
Start from models.py, User, Permission and UserManager. As far as I see there are no special hooks to set up predefined permissions when new user created.Sanitary

© 2022 - 2024 — McMap. All rights reserved.