diff options
author | David Sanders <shang.xiao.sanders@gmail.com> | 2023-03-28 16:45:46 +1100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-04-20 09:12:03 +0200 |
commit | 9967faab0b664306c377fee931317e0dccb134ea (patch) | |
tree | 039b8cd3f6572db5fa32e7569e2e7b96665c7600 | |
parent | f80dbcf7dccc7227eade1a02d413fc65fc6f53ef (diff) | |
download | django-9967faab0b664306c377fee931317e0dccb134ea.tar.gz |
[4.2.x] Fixed #34440 -- Doc'd that & queryset operator works similar to chaining.
Backport of 0494efddc422716431b92896899284b6afebb23a from main
-rw-r--r-- | docs/ref/models/querysets.txt | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 38364559b2..86fc3bc8ad 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1997,15 +1997,13 @@ Combined querysets must use the same model. 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:: Model.objects.filter(x=1) & Model.objects.filter(y=2) - Model.objects.filter(x=1, y=2) - from django.db.models import Q - - Model.objects.filter(Q(x=1) & Q(y=2)) + Model.objects.filter(x=1).filter(y=2) SQL equivalent: |