用户表----部门表是多对多关系,字段是department,
用set可以对department来进行赋值操作
is_true = UserProfile.objects.filter(username=user["user_no"]).all()
if is_true:
is_true[0].name = user["user_name"]
is_true[0].mobile = user["telf"]
is_true[0].email = user["email"]
is_true[0].position = user["position"]
is_true[0].is_active = 1 if user["is_still"] else 0
is_true[0].department.set(user_dict[user["user_no"]])
else:
new_user = UserProfile(username=user["user_no"], name=user["user_name"], mobile=user["telf"],
email=user["email"], image="image/default.png",
position=user["position"],
is_active=1 if user["is_still"] else 0
)
new_user.save()
new_user.department.set(user_dict[user["user_no"]])
因篇幅问题不能全部显示,请点此查看更多更全内容