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

只愿长相守 提交于 2019-12-04 03:33:01

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/12312931/how-do-i-define-default-permissions-for-users-in-django-guardian

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!