Skip to content

Commit 1f08717

Browse files
committed
use include
1 parent c888551 commit 1f08717

File tree

3 files changed

+45
-28
lines changed

3 files changed

+45
-28
lines changed

snooty.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ api = "https://django-mongodb.readthedocs.io/en/latest/"
1313
mdb-server = "MongoDB Server"
1414
django-version = "5.0"
1515
django-docs = "https://docs.djangoproject.com/en/{+django-version+}"
16+
framework = "Django"

source/includes/use-sample-data.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
The |model-classes| an inner ``Meta`` class and a ``__str__()`` method.
2+
To learn about these model features, see :ref:`django-models-define` in the
3+
Create Models guide.
4+
5+
Run Code Examples
6+
`````````````````
7+
8+
You can use the Python interactive shell to run the code examples.
9+
To enter the shell, run the following command from your project's
10+
root directory:
11+
12+
.. code-block:: bash
13+
14+
python manage.py shell
15+
16+
After entering the Python shell, ensure that you import the following models and
17+
modules:
18+
19+
|model-imports|
20+
21+
To learn how to create a {+framework+} application that uses the ``Movie``
22+
model and the Python interactive shell to interact with MongoDB documents,
23+
visit the :ref:`django-get-started` tutorial.

source/interact-data/specify-a-query.txt

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ complex matching criteria.
3333
Query API
3434
~~~~~~~~~
3535

36-
The Django ``QuerySet`` API provides methods that allow you to retrieve
36+
The {+framework+} ``QuerySet`` API provides methods that allow you to retrieve
3737
model objects. To run a MongoDB database query, call ``QuerySet`` methods
3838
on your model's manager. The ``Manager`` class handles database
3939
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``
4141
to every model class.
4242

4343
When you assign a ``QuerySet`` to a variable, {+django-odm+} does not
4444
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``
4646
cache. Future evaluations of the ``QuerySet`` use the cached results.
4747

4848
.. tip::
4949

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.
5252

5353
Sample Data
5454
~~~~~~~~~~~
@@ -64,26 +64,19 @@ of its ``awards`` field. These model classes have the following definitions:
6464
:language: python
6565
:copyable:
6666

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
7068

71-
.. code-block:: bash
69+
.. replacement:: model-classes
7270

73-
python manage.py shell
71+
``Movie`` model includes
7472

75-
After entering the Python shell, ensure that you import the following models and
76-
modules:
73+
.. replacement:: model-imports
7774

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
8376

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
8780

8881
Run a Query
8982
-----------
@@ -243,7 +236,7 @@ from the results:
243236
Run Raw Database Queries
244237
~~~~~~~~~~~~~~~~~~~~~~~~
245238

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
247240
does not support, you can use the ``raw_aggregate()`` method. This
248241
method allows you to specify your query criteria in a MongoDB
249242
aggregation pipeline, which you pass as an argument to
@@ -275,7 +268,7 @@ expression matching, and year value matching for datetime fields.
275268

276269
To view a full list of lookup types, see `Field lookups
277270
<{+django-docs+}/ref/models/querysets/#field-lookups>`__ in the
278-
``QuerySet`` Django API reference.
271+
``QuerySet`` {+framework+} API reference.
279272

280273
This section describes how to refine your query filters
281274
in the following ways:
@@ -424,15 +417,15 @@ in the following ways:
424417
- Pass multiple query filters to your query method, separated
425418
by commas. To view an example, see `Retrieving objects
426419
<{+django-docs+}/topics/db/queries/#retrieving-objects>`__ in the
427-
Django documentation.
420+
{+framework+} documentation.
428421

429422
- 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+}
431424
documentation.
432425

433426
- Use ``Q`` objects and separate each object with a logical operator.
434427
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+}
436429
documentation.
437430

438431
Q Object Example
@@ -766,7 +759,7 @@ provided ``KT()`` expressions.
766759
.. tip::
767760

768761
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:
770763

771764
- `KT() expressions <{+django-docs+}/topics/db/queries/#module-django.db.models.fields.json>`__
772765
- `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.
842835
To learn how to perform other ``QuerySet`` operations, see the
843836
:ref:`django-crud` guide.
844837

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

Comments
 (0)