【发布时间】:2013-12-20 02:31:46
【问题描述】:
Django 1.5,python 2.6
模型在特定条件下自动创建用户:
User.objects.get_or_create(username=new_user_name, is_staff=True)
u = User.objects.get(username=new_user_name)
u.set_password('temporary')
除了设置用户名、密码和 is_staff 状态之外,我还想设置用户的权限 - 类似:
u.user_permissions('Can view poll')
或
u.set_permissions('Can change poll')
这可能吗?谢谢!
【问题讨论】:
标签: python django django-admin django-authentication