mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
[4.2.x] Fixed #34440 -- Doc'd that & queryset operator works similar to chaining.
Backport of 0494efddc422716431b92896899284b6afebb23a from main
This commit is contained in:
parent
f80dbcf7dc
commit
9967faab0b
@ -1997,15 +1997,13 @@ Combined querysets must use the same model.
|
|||||||
AND (``&``)
|
AND (``&``)
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
Combines two ``QuerySet``\s using the SQL ``AND`` operator.
|
Combines two ``QuerySet``\s using the SQL ``AND`` operator in a manner similar
|
||||||
|
to chaining filters.
|
||||||
|
|
||||||
The following are equivalent::
|
The following are equivalent::
|
||||||
|
|
||||||
Model.objects.filter(x=1) & Model.objects.filter(y=2)
|
Model.objects.filter(x=1) & Model.objects.filter(y=2)
|
||||||
Model.objects.filter(x=1, y=2)
|
Model.objects.filter(x=1).filter(y=2)
|
||||||
from django.db.models import Q
|
|
||||||
|
|
||||||
Model.objects.filter(Q(x=1) & Q(y=2))
|
|
||||||
|
|
||||||
SQL equivalent:
|
SQL equivalent:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user