Django | Models where clause
How to construct a where clause 开发者_开发知识库using Django models:
insert in to tablename where email=emailaddress
Thanks.
I think you are rather looking for a possibility to UPDATE an existing object.
obj=MyModel.objects.get(email=emailaddress)
obj.name = 'xxxx'
obj.save()
In case the email address is not unique, which is strange but let's suppose that, you should use the filter method and loop on result
users = MyObject.objects.filter(email=emailaddress)
for u in users:
# your change here
u.is_superuser = True
u.save()
精彩评论