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)