@@ -101,9 +101,9 @@ Retrieve All Documents
101
101
~~~~~~~~~~~~~~~~~~~~~~
102
102
103
103
To retrieve all documents from a collection, call the ``all()``
104
- method on the collection's corresponding Django model.
104
+ function on the collection's corresponding Django model.
105
105
106
- The following example calls the ``all()`` method on the
106
+ The following example calls the ``all()`` function on the
107
107
``Movie`` model to retrieve all documents in the ``sample_mflix.movies``
108
108
collection:
109
109
@@ -135,11 +135,11 @@ Retrieve Matching Documents
135
135
~~~~~~~~~~~~~~~~~~~~~~~~~~~
136
136
137
137
To query a collection for documents that match a set of criteria,
138
- call the ``filter()`` method on the collection's corresponding Django
139
- model. Pass a query filter to the ``filter()`` method that specifies your
138
+ call the ``filter()`` function on the collection's corresponding Django
139
+ model. Pass a query filter to the ``filter()`` function that specifies your
140
140
query criteria.
141
141
142
- The following example calls the ``filter()`` method on the
142
+ The following example calls the ``filter()`` function on the
143
143
``Movie`` model to query the ``sample_mflix.movies`` collection
144
144
for documents that have a ``runtime`` value of ``300``:
145
145
@@ -163,19 +163,19 @@ Retrieve One Document
163
163
~~~~~~~~~~~~~~~~~~~~~
164
164
165
165
To retrieve one document from a collection, call the ``get()``
166
- method on the collection's corresponding Django model. Pass
167
- a query filter to the ``get()`` method that specifies your
166
+ function on the collection's corresponding Django model. Pass
167
+ a query filter to the ``get()`` function that specifies your
168
168
query criteria.
169
169
170
170
.. important::
171
171
172
172
If your query matches no documents or multiple documents, the ``get()``
173
- method generates an error. To retrieve one document from a query
173
+ function generates an error. To retrieve one document from a query
174
174
that might match multiple, use the :ref:`first() <django-query-first>`
175
- method .
175
+ function .
176
176
177
177
178
- The following example calls the ``get()`` method on the
178
+ The following example calls the ``get()`` function on the
179
179
``Movie`` model to retrieve one document that has a ``title``
180
180
value of ``"Finding Nemo"``:
181
181
@@ -198,11 +198,11 @@ Exclude Matching Documents
198
198
~~~~~~~~~~~~~~~~~~~~~~~~~~
199
199
200
200
To query a collection for documents that do not meet your
201
- search criteria, call the ``exclude()`` method on the collection's
201
+ search criteria, call the ``exclude()`` function on the collection's
202
202
corresponding Django model. Pass the exclusion criteria as an
203
- argument to the ``exclude()`` method .
203
+ argument to the ``exclude()`` function .
204
204
205
- The following example calls the ``exclude()`` method on the
205
+ The following example calls the ``exclude()`` function on the
206
206
``Movie`` model to exclude documents released before January 1,
207
207
1980 from the results:
208
208
@@ -489,7 +489,7 @@ Sort Results
489
489
~~~~~~~~~~~~
490
490
491
491
You can provide a sort order for your query results by using the
492
- ``order_by()`` method . To specify an ascending sort based on values
492
+ ``order_by()`` function . To specify an ascending sort based on values
493
493
of a given field, pass the field name as an argument. To specify a descending
494
494
sort, pass the field name prefixed with a minus symbol (``-``) as an argument.
495
495
@@ -498,7 +498,7 @@ Example
498
498
499
499
This example performs the following actions:
500
500
501
- - Calls the ``filter()`` method on the ``Movie`` model to query
501
+ - Calls the ``filter()`` function on the ``Movie`` model to query
502
502
the ``sample_mflix.movies`` collection
503
503
- Queries documents that have a ``title`` value starting
504
504
with the text ``"Rocky"``
@@ -542,12 +542,15 @@ If you omit the ``<start>`` value, the query returns each result,
542
542
beginning with the first match, until it returns the number specified
543
543
by the ``<end>`` value.
544
544
545
+ If you omit the ``<end>`` value, the query returns each result
546
+ but skips the number of initial results specified by ``<start>``.
547
+
545
548
Example
546
549
```````
547
550
548
551
This example performs the following actions:
549
552
550
- - Calls the ``filter()`` method on the ``Movie`` model to query
553
+ - Calls the ``filter()`` function on the ``Movie`` model to query
551
554
the ``sample_mflix.movies`` collection
552
555
- Queries documents that have a ``released`` value of
553
556
``datetime(2010, 7, 16)`` (July 16, 2010)
@@ -572,11 +575,11 @@ Retrieve the First Result
572
575
~~~~~~~~~~~~~~~~~~~~~~~~~
573
576
574
577
To retrieve the first result from a query that might match
575
- multiple results, chain the ``first()`` method to the ``filter()``
576
- method . Pass a query filter to the ``filter()`` method that specifies your
578
+ multiple results, chain the ``first()`` function to the ``filter()``
579
+ function . Pass a query filter to the ``filter()`` function that specifies your
577
580
query criteria.
578
581
579
- The following example calls the ``filter()`` and ``first()`` methods on the
582
+ The following example calls the ``filter()`` and ``first()`` functions on the
580
583
``Movie`` model to query the ``sample_mflix.movies`` collection
581
584
for the first document in which the ``genres`` value is
582
585
``["Crime", "Comedy"]``:
@@ -644,9 +647,9 @@ for values of its nested ``votes`` field that exceed ``900000``:
644
647
JSONField Transforms
645
648
````````````````````
646
649
647
- You can use the ``KT()`` method to specify a key, index, or path
650
+ You can use the ``KT()`` function to specify a key, index, or path
648
651
transform of a ``JSONField``. For example, the following code uses
649
- the ``annotate()`` and ``KT()`` methods to create a new ``score`` key, which
652
+ the ``annotate()`` and ``KT()`` functions to create a new ``score`` key, which
650
653
stores ``imdb.rating`` nested field values. Then, the code sorts
651
654
each document in the ``sample_mflix.movies`` collection by
652
655
their descending ``score`` values:
@@ -688,7 +691,7 @@ for a document whose primary key is ``ObjectId("573a1394f29313caabce0d37")``:
688
691
689
692
.. input:: /includes/interact-data/specify-a-query.py
690
693
:start-after: start-primary-key-pk
691
- :end-before: end-primary-keypk
694
+ :end-before: end-primary-key-pk
692
695
:language: python
693
696
694
697
.. output::
0 commit comments