标签:ar 数据 ad user 结构 而且 Go django object
User.objects.filter(id=userid).delete()#删除id=userid的数据
一对多:
role = UserRole.objects.get(id=roleid)
user = User.objects.get(id=i)(get取数据时只能取一条,而且必须取一条不然会报错)
role.user_set.add(user)
多对多:
m = Modular.objects.get(id=i)
a = User.objects.get(id=userid)
m.users.remove(a)(users为表结构多对多字段)
m = Modular.objects.get(id=i)
a = User.objects.get(id=userid)
m.users.add(a)
标签:ar 数据 ad user 结构 而且 Go django object
原文地址:http://www.cnblogs.com/Mohf/p/4026991.html