有两大用处
- FilteredRelation类允许为查询集增加一个ON从句
- 可以在多个join中语句直接引用变量
from django.db.models import FilteredRelation, Q
result_1 = Restaurant.objects.annotate(pizzas_vegetarian=FilteredRelation('pizzas', condition=Q(pizzas__vegetarian=True), ), ).filter(
pizzas_vegetarian__name__icontains='mozzarella')
标签:__,FilteredRelation,vegetarian,用法,django,pizzas
From: https://www.cnblogs.com/guanchaoguo/p/17061065.html