Django_数据库增删改查——改和删

# 批量修改
models.Account.objects.filter(username='elina').update(password="Luffy#21")
 
# 单条修改
obj = models.Account.objects.get(username='linux')
obj.username = 'python'
obj.save()
 
 
# 批量删除
models.User.objects.get(password='oldboy').delete()
 
# 单条删除
obj = models.User.objects.get(id=3)
obj.delete()
posted @ 2020-04-08 22:49  手可摘星辰。  阅读(155)  评论(0编辑  收藏  举报