@@ -33,22 +33,22 @@ complex matching criteria.
33
33
Query API
34
34
~~~~~~~~~
35
35
36
- The Django ``QuerySet`` API provides methods that allow you to retrieve
36
+ The {+framework+} ``QuerySet`` API provides methods that allow you to retrieve
37
37
model objects. To run a MongoDB database query, call ``QuerySet`` methods
38
38
on your model's manager. The ``Manager`` class handles database
39
39
operations and allows you to interact with your MongoDB data by referencing
40
- Django models. By default, Django adds a ``Manager`` named ``objects``
40
+ {+framework+} models. By default, {+framework+} adds a ``Manager`` named ``objects``
41
41
to every model class.
42
42
43
43
When you assign a ``QuerySet`` to a variable, {+django-odm+} does not
44
44
perform the operation until you evaluate the variable. After
45
- evaluating the ``QuerySet``, Django saves the query results in the ``QuerySet``
45
+ evaluating the ``QuerySet``, {+framework+} saves the query results in the ``QuerySet``
46
46
cache. Future evaluations of the ``QuerySet`` use the cached results.
47
47
48
48
.. tip::
49
49
50
- To learn more about the Django ``QuerySet`` API, see `QuerySet API reference
51
- <{+django-docs+}/ref/models/querysets/>`__ in the Django documentation.
50
+ To learn more about the {+framework+} ``QuerySet`` API, see `QuerySet API reference
51
+ <{+django-docs+}/ref/models/querysets/>`__ in the {+framework+} documentation.
52
52
53
53
Sample Data
54
54
~~~~~~~~~~~
@@ -64,26 +64,19 @@ of its ``awards`` field. These model classes have the following definitions:
64
64
:language: python
65
65
:copyable:
66
66
67
- You can use the Python interactive shell to run the code examples.
68
- To enter the shell, run the following command from your project's
69
- root directory:
67
+ .. include:: /includes/use-sample-data.rst
70
68
71
- .. code-block :: bash
69
+ .. replacement :: model-classes
72
70
73
- python manage.py shell
71
+ ``Movie`` model includes
74
72
75
- After entering the Python shell, ensure that you import the following models and
76
- modules:
73
+ .. replacement:: model-imports
77
74
78
- .. code-block:: python
79
-
80
- from <your application name>.models import Movie, Award
81
- from django.utils import timezone
82
- from datetime import datetime
75
+ .. code-block:: python
83
76
84
- To learn how to create a Django application that uses the `` Movie``
85
- model and the Python interactive shell to interact with MongoDB documents,
86
- visit the :ref:`django-get-started` tutorial.
77
+ from <your application name>.models import Movie, Award
78
+ from django.utils import timezone
79
+ from datetime import datetime
87
80
88
81
Run a Query
89
82
-----------
@@ -243,7 +236,7 @@ from the results:
243
236
Run Raw Database Queries
244
237
~~~~~~~~~~~~~~~~~~~~~~~~
245
238
246
- If you want to run complex queries that Django 's query API
239
+ If you want to run complex queries that {+framework+} 's query API
247
240
does not support, you can use the ``raw_aggregate()`` method. This
248
241
method allows you to specify your query criteria in a MongoDB
249
242
aggregation pipeline, which you pass as an argument to
@@ -275,7 +268,7 @@ expression matching, and year value matching for datetime fields.
275
268
276
269
To view a full list of lookup types, see `Field lookups
277
270
<{+django-docs+}/ref/models/querysets/#field-lookups>`__ in the
278
- ``QuerySet`` Django API reference.
271
+ ``QuerySet`` {+framework+} API reference.
279
272
280
273
This section describes how to refine your query filters
281
274
in the following ways:
@@ -424,15 +417,15 @@ in the following ways:
424
417
- Pass multiple query filters to your query method, separated
425
418
by commas. To view an example, see `Retrieving objects
426
419
<{+django-docs+}/topics/db/queries/#retrieving-objects>`__ in the
427
- Django documentation.
420
+ {+framework+} documentation.
428
421
429
422
- Chain query methods together. To learn more, see `Chaining filters
430
- <{+django-docs+}/topics/db/queries/#chaining-filters>`__ in the Django
423
+ <{+django-docs+}/topics/db/queries/#chaining-filters>`__ in the {+framework+}
431
424
documentation.
432
425
433
426
- Use ``Q`` objects and separate each object with a logical operator.
434
427
To learn more, see `Complex lookups with Q objects
435
- <{+django-docs+}/topics/db/queries/#complex-lookups-with-q-objects>`__ in the Django
428
+ <{+django-docs+}/topics/db/queries/#complex-lookups-with-q-objects>`__ in the {+framework+}
436
429
documentation.
437
430
438
431
Q Object Example
@@ -766,7 +759,7 @@ provided ``KT()`` expressions.
766
759
.. tip::
767
760
768
761
To learn more about ``KT()`` expressions and the ``annotate()`` method,
769
- see the following resources in the Django documentation:
762
+ see the following resources in the {+framework+} documentation:
770
763
771
764
- `KT() expressions <{+django-docs+}/topics/db/queries/#module-django.db.models.fields.json>`__
772
765
- `annotate() <{+django-docs+}/ref/models/querysets/#django.db.models.query.QuerySet.annotate>`__
@@ -842,5 +835,5 @@ pipeline syntax, see the :ref:`django-raw-queries` guide.
842
835
To learn how to perform other ``QuerySet`` operations, see the
843
836
:ref:`django-crud` guide.
844
837
845
- To learn more about Django queries, see `Making queries <{+django-docs+}/topics/db/queries>`__
846
- in the Django documentation.
838
+ To learn more about {+framework+} queries, see `Making queries <{+django-docs+}/topics/db/queries>`__
839
+ in the {+framework+} documentation.
0 commit comments