我需要在django orm中这样做。
SELECT * FROM offer WHERE country_id = 1 OR mundial = 1;
如何在django中执行'OR',如:
list = offer.objects.filter(country_id=1, #HOW DO I PUT 'OR' HERE?)
答案 0 :(得分:4)
使用Q
:
from django.db.models import Q
list = offer.objects.filter(Q(country_id=1) | Q(something_else=1))