在开发的时候,用户要求在认证的时候自动添加xadmin登录账户和分配组权限
from django.contrib.auth.models import Group,User from django.http import
JsonResponse def test(req): name=req.POST['name'] account=req.POST['account']
password=req.POST['password'] an=Group.objects.filter(id=1).first() #二级管理组
是管理员在xadmin后台添加的权限组 user = User(username=account) user.set_password(password)
user.is_superuser = False user.is_active = True user.first_name = name
user.is_staff = True user.save() #先生成用户 user.groups.add(an) return
JsonResponse({'ret':0,'msg':'success'})
 

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信