Opened 8 years ago
Closed 8 years ago
#28177 closed Cleanup/optimization (duplicate)
Clarify documentation with regards to Q objects and OR
Reported by: | Yoong Kang Lim | Owned by: | Yoong Kang Lim |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In the QuerySet documentation it is written:
In general, Q() objects make it possible to define and reuse conditions. This permits the construction of complex database queries using |
(OR) and & (AND) operators; in particular, it is not otherwise possible to use OR in QuerySets.
It's possible to use OR without Q objects by simply using the | operator on two querysets, e.g:
queryset = Article.objects.filter(headline__startswith='Hello') | Article.objects.filter(headline__startswith='Goodbye')
Examples of this still remain in in the or_lookups tests, although I must confess I haven't used this style much.
Perhaps the wording should be changed, or simply removed.
Change History (2)
comment:1 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 8 years ago
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
Type: | Uncategorized → Cleanup/optimization |
Duplicate of #21333