API Reference¶
Much of the QuerySet API is implemented by QuerySetSequence, but it is
not fully compatible.
Summary of Supported APIs¶
| Method | Implemented? | Notes |
|---|---|---|
filter() |
✓ | See [1] for information on the QuerySet lookup: '#'. |
exclude() |
✓ | See [1] for information on the QuerySet lookup: '#'. |
annotate() |
✓ | |
alias() |
✗ | |
order_by() |
✓ | Does not support random ordering (e.g. order_by('?')). See [1] for
information on the QuerySet lookup: '#'. |
reverse() |
✓ | |
distinct() |
✓ | Does not support calling distinct() if there are multiple underlying
QuerySet instances of the same model. |
values() |
✓ | See [1] for information on including the QuerySet index: '#'. |
values_list() |
✓ | See [1] for information on including the QuerySet index: '#'. |
dates() |
✗ | |
datetimes() |
✗ | |
none() |
✓ | |
all() |
✓ | |
union() |
✗ | |
intersection() |
✗ | |
difference() |
✗ | |
select_related() |
✓ | |
prefetch_related() |
✓ | |
extra() |
✓ | |
defer() |
✓ | |
only() |
✓ | |
using() |
✓ | |
select_for_update() |
✗ | |
raw() |
✗ |
| Operator | Implemented? | Notes |
|---|---|---|
AND (&) |
✓ | A QuerySetSequence can be combined with a QuerySet. The
QuerySets in the QuerySetSequence are filtered to ones matching
the same Model. Each of those is ANDed with the other QuerySet. |
OR (|) |
✓ | A QuerySetSequence can be combined with a QuerySet or
QuerySetSequence. When combining with a QuerySet, it is added to
the QuerySetSequence. Combiningg with another QuerySetSequence
adds together the two underlying sets of QuerySets. |
| Method | Implemented? | Notes |
|---|---|---|
get() |
✓ | See [1] for information on the QuerySet lookup: '#'. |
aget() |
✓ | |
create() |
✗ | Cannot be implemented in QuerySetSequence. |
acreate() |
✗ | Cannot be implemented in QuerySetSequence. |
get_or_create() |
✗ | Cannot be implemented in QuerySetSequence. |
aget_or_create() |
✗ | Cannot be implemented in QuerySetSequence. |
update_or_create() |
✗ | Cannot be implemented in QuerySetSequence. |
aupdate_or_create() |
✗ | Cannot be implemented in QuerySetSequence. |
bulk_create() |
✗ | Cannot be implemented in QuerySetSequence. |
abulk_create() |
✗ | Cannot be implemented in QuerySetSequence. |
bulk_update() |
✗ | Cannot be implemented in QuerySetSequence. |
abulk_update() |
✗ | Cannot be implemented in QuerySetSequence. |
count() |
✓ | |
acount() |
✓ | |
in_bulk() |
✗ | Cannot be implemented in QuerySetSequence. |
ain_bulk() |
✗ | Cannot be implemented in QuerySetSequence. |
iterator() |
✓ | |
aiterator() |
✗ | |
latest() |
✓ | If no fields are given, get_latest_by on each model is required to
be identical. |
alatest() |
✗ | |
earliest() |
✓ | See the docuemntation for latest(). |
aearliest() |
✗ | |
first() |
✓ | If no ordering is set this is essentially the same as calling
first() on the first QuerySet, if there is an ordering, the
result of first() for each QuerySet is compared and the “first”
value is returned. |
afirst() |
✗ | |
last() |
✓ | See the documentation for first(). |
alast() |
✗ | |
aggregate() |
✗ | |
aaggregate() |
✗ | |
exists() |
✓ | |
aexists() |
✓ | |
contains() |
✓ | |
acontains() |
✗ | |
update() |
✓ | |
aupdate() |
✗ | |
delete() |
✓ | |
adelete() |
✗ | |
as_manager() |
✓ | |
explain() |
✓ | |
aexplain() |
✗ |
| Method | Notes |
|---|---|
get_querysets() |
Returns the list of QuerySet objects that comprise the sequence.
Note, if any methods have been called which modify the
QuerySetSequence, the QuerySet objects returned by this
method will be similarly modified. The order of the QuerySet
objects within the list is not guaranteed. |
| [1] | (1, 2, 3, 4, 5, 6)
A few examples are below: # Order first by QuerySet, then by the value of the 'title' field.
QuerySetSequence(...).order_by('#', 'title')
# Filter out the first QuerySet.
QuerySetSequence(...).filter(**{'#__gt': 0})
Note Ordering first by Warning Not all lookups are supported when using
|