美文网首页
Django批量更新数据

Django批量更新数据

作者: Andrew玩Android | 来源:发表于2017-07-21 20:12 被阅读1159次

Python Shell下更新数据

1. 进入shell python manage.py shell

2. 更新数据:

1. 导入model
 from exams.models import MatchTestApply

2. 过滤后更新 (根据自己业务更改过滤条件和更新条件)
 MatchTestApply.objects.filter(matched_score=None).update(matched_score=-1)

3. 会输出更改行数

4. 退出shell:`exit()` 回车

相关文章

网友评论

      本文标题:Django批量更新数据

      本文链接:https://www.haomeiwen.com/subject/ibzekxtx.html