如何使用Django模型构造where子句:
insert in to tablename where email=emailaddress谢谢。
发布于 2010-05-19 09:16:37
我认为您正在寻找一种更新现有对象的可能性。
obj=MyModel.objects.get(email=emailaddress)
obj.name = 'xxxx'
obj.save()发布于 2015-09-02 05:02:51
如果电子邮件地址不是唯一的,这很奇怪,但让我们假设一下,您应该使用filter方法并对result进行循环
users = MyObject.objects.filter(email=emailaddress)
for u in users:
# your change here
u.is_superuser = True
u.save()https://stackoverflow.com/questions/2861127
复制相似问题