Q,F查询
引包:
from django.db.models import F,Q
单关键字查询
SELECT `myapp_article`.`id`, `myapp_article`.`title`, `myapp_article`.`context`, `myapp_article`.`account_id`, `myapp_article`.`pub_date` F
ROM `myapp_article` WHERE (`myapp_article`.`context` = 'xt' AND `myapp_article`.`title` = 'aa') LIMIT 21; args=('xt', 'aa')
把每本书的价格加10
Book.object.all().update(price=F('price')+10)
| 或的关系
count3=Article.objects.filter (Q(context="xt")|Q(title='cc'))
SELECT `myapp_article`.`id`, `myapp_article`.`title`, `myapp_article`.`context`, `myapp_ar
ticle`.`account_id`, `myapp_article`.`pub_date` FROM `myapp_article` WHERE (`myapp_article`.`conte
xt` = 'xt' OR `myapp_article`.`title` = 'cc') LIMIT 21; args=('xt', 'cc')
~Q 非的关系