使用Django模型库时,在过滤器中创建"或"语句的语法是什么?

blu*_*lds 1 python django

我正在寻找正确的语法:

SomeModel.objects.filter(propertyA = 'foo' OR propertyB = 'bar')
Run Code Online (Sandbox Code Playgroud)

这里的语法是什么?

Zas*_*has 6

请看这里:https://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

这将是 :

from django.db.models import Q
SomeModel.objects.filter(Q(propertyA=foo) | Q(propertyB=bar))
Run Code Online (Sandbox Code Playgroud)