diff --git a/snooty.toml b/snooty.toml index 958dedf..01b8586 100644 --- a/snooty.toml +++ b/snooty.toml @@ -3,7 +3,7 @@ title = "Django MongoDB Backend" intersphinx = [ "https://www.mongodb.com/docs/manual/objects.inv", "https://www.mongodb.com/docs/atlas/objects.inv", - "http://docs.djangoproject.com/en/5.0/_objects/" + "http://docs.djangoproject.com/en/5.0/_objects", ] toc_landing_pages = [ diff --git a/source/compatibility.txt b/source/compatibility.txt index d3c7680..fe6cf0f 100644 --- a/source/compatibility.txt +++ b/source/compatibility.txt @@ -23,7 +23,7 @@ MongoDB Compatibility {+django-odm+} uses the PyMongo driver to interact with MongoDB. The {+mdb-server+} versions that your application supports depend on your PyMongo version. To view PyMongo and {+mdb-server+} compatibility information, see `MongoDB Compatibility -`__ +<{+pymongo-docs+}/compatibility/#mongodb-compatibility>`__ in the PyMongo documentation. PyMongo Compatibility diff --git a/source/connect.txt b/source/connect.txt index c37e27f..946e253 100644 --- a/source/connect.txt +++ b/source/connect.txt @@ -148,11 +148,11 @@ function accepts the following arguments: - ``conn_max_age``: Configures persistent database connections. This argument is optional. To learn more, see `Persistent connections <{+django-docs+}/ref/databases/#persistent-database-connections>`__ - in the Django documentation. + in the {+framework+} documentation. - ``test``: Provides a dictionary of settings for test databases. This argument is optional. To learn more, see `the TEST setting <{+django-docs+}/ref/settings/#test>`__ - in the Django documentation. + in the {+framework+} documentation. Example ``````` @@ -175,5 +175,5 @@ To view a sample project that configures a MongoDB database connection, see the :ref:`django-get-started-connect` step in the Getting Started tutorial. -To learn more about Django settings, see `Settings <{+django-docs+}/ref/settings/>`__ -in the Django documentation. \ No newline at end of file +To learn more about {+framework+} settings, see `Settings <{+django-docs+}/ref/settings/>`__ +in the {+framework+} documentation. \ No newline at end of file diff --git a/source/get-started.txt b/source/get-started.txt index 142cddf..5a41e39 100644 --- a/source/get-started.txt +++ b/source/get-started.txt @@ -15,7 +15,7 @@ Get Started with {+django-odm+} :values: tutorial .. meta:: - :description: Learn how to create an app to connect to a MongoDB deployment by using Django MongoDB Backend. + :description: Learn how to create an app to connect to a MongoDB deployment by using {+django-odm+}. :keywords: quick start, tutorial, basics .. toctree:: @@ -30,8 +30,8 @@ Get Started with {+django-odm+} Create an Admin Site Next Steps -{+django-odm+} is a Django database backend that uses PyMongo to connect -to MongoDB. This tutorial shows you how to create a Django app, connect to +{+django-odm+} is a {+framework+} database backend that uses PyMongo to connect +to MongoDB. This tutorial shows you how to create a {+framework+} app, connect to a MongoDB cluster hosted on MongoDB Atlas, and interact with data in your cluster. .. tip:: @@ -40,5 +40,5 @@ a MongoDB cluster hosted on MongoDB Atlas, and interact with data in your cluste deployments. You can create your own free (no credit card required) MongoDB Atlas deployment by following the steps in this guide. -Follow this tutorial to connect a sample Django application to a MongoDB Atlas +Follow this tutorial to connect a sample {+framework+} application to a MongoDB Atlas deployment. \ No newline at end of file diff --git a/source/get-started/connect-mongodb.txt b/source/get-started/connect-mongodb.txt index 29d73e5..84b23c1 100644 --- a/source/get-started/connect-mongodb.txt +++ b/source/get-started/connect-mongodb.txt @@ -12,12 +12,12 @@ Configure your MongoDB Connection :keywords: app, odm, code example After installing {+django-odm+} and creating a MongoDB Atlas deployment, -you can create a Django project that connects to MongoDB. +you can create a {+framework+} project that connects to MongoDB. .. procedure:: :style: connected - .. step:: Create a Django project + .. step:: Create a {+framework+} project From your shell, run the following command to create a new Django project called ``quickstart`` based on a custom template: @@ -28,11 +28,11 @@ you can create a Django project that connects to MongoDB. .. note:: Project Template - The ``django-mongodb-project`` template resembles the default Django project + The ``django-mongodb-project`` template resembles the default {+framework+} project template but makes the following changes: - Includes MongoDB-specific migrations - - Modifies the ``settings.py`` file to instruct Django + - Modifies the ``settings.py`` file to instruct {+framework+} to use an ``ObjectId`` value as each model's primary key After running this command, your ``quickstart`` project has @@ -69,7 +69,7 @@ you can create a Django project that connects to MongoDB. Replace the ```` placeholder with the connection string that you copied from the :ref:`django-get-started-connection-string` - step of this guide. This configures your Django app to connect to + step of this guide. This configures your {+framework+} app to connect to your Atlas deployment and access the ``sample_mflix`` sample database. .. step:: Start the server @@ -84,5 +84,5 @@ you can create a Django project that connects to MongoDB. Then, visit http://127.0.0.1:8000/. This page displays a "Congratulations!" message and an image of a rocket. -After completing these steps, you have a Django project configured +After completing these steps, you have a {+framework+} project configured to use MongoDB. \ No newline at end of file diff --git a/source/get-started/connection-string.txt b/source/get-started/connection-string.txt index 905d7d0..fc6dee5 100644 --- a/source/get-started/connection-string.txt +++ b/source/get-started/connection-string.txt @@ -13,9 +13,6 @@ The connection string includes the hostname or IP address and port of your deployment, the authentication mechanism, user credentials when applicable, and connection options. -To connect to an instance or deployment not hosted on Atlas, see -:ref:`pymongo-connection-targets` in the PyMongo documentation. - .. procedure:: :style: connected @@ -52,9 +49,9 @@ To connect to an instance or deployment not hosted on Atlas, see .. code-block:: none :copyable: false - mongodb+srv://:@samplecluster.jkiff1s.mongodb.net/?retryWrites=true&w=majority&appName=SampleCluster + mongodb+srv://:@samplecluster.ojeyz.mongodb.net/?retryWrites=true&w=majority&appName=SampleCluster - Replace the ```` and ```` placeholders with + Replace the ```` and ```` placeholders with your database user's username and password. .. step:: Add a database to your connection string @@ -65,7 +62,7 @@ To connect to an instance or deployment not hosted on Atlas, see .. code-block:: none :copyable: false - mongodb+srv://:@samplecluster.jkiff1s.mongodb.net/?retryWrites=true&w=majority&appName=SampleCluster + mongodb+srv://:@samplecluster.ojeyz.mongodb.net/?retryWrites=true&w=majority&appName=SampleCluster Replace the ```` placeholder with ``sample_mflix`` to configure a connection to the ``sample_mflix`` Atlas sample database. diff --git a/source/get-started/create-admin.txt b/source/get-started/create-admin.txt index 70945fe..bcac068 100644 --- a/source/get-started/create-admin.txt +++ b/source/get-started/create-admin.txt @@ -11,10 +11,10 @@ Create an Admin Site .. meta:: :keywords: app, odm, code example -You can create a Django admin site to edit your application's -data from a web interface. To learn more about the Django admin -site and its features, see `The Django admin site `__ -in the Django documentation. +You can create a {+framework+} admin site to edit your application's +data from a web interface. To learn more about the {+framework+} admin +site and its features, see `The Django admin site <{+django-docs+}/ref/contrib/admin/>`__ +in the {+framework+} documentation. .. procedure:: :style: connected @@ -59,7 +59,7 @@ in the Django documentation. screen: .. figure:: /includes/figures/django_admin_login.png - :alt: The login screen on the Django admin page. + :alt: The login screen on the {+framework+} admin page. Enter the username and password created in the previous step to log in to the site. @@ -126,5 +126,5 @@ in the Django documentation. Then, click the :guilabel:`SAVE` button below the viewer's information to save your changes. -After completing these steps, you can access the Django +After completing these steps, you can access the {+framework+} admin site and use it to edit your ``Viewer`` objects. \ No newline at end of file diff --git a/source/get-started/create-app.txt b/source/get-started/create-app.txt index 8ab479a..f4ae2e5 100644 --- a/source/get-started/create-app.txt +++ b/source/get-started/create-app.txt @@ -38,7 +38,7 @@ To learn more about the ``sample_mflix`` database, see :atlas:`Sample Mflix Data The ``django-mongodb-app`` template ensures that your ``app.py`` file includes the line ``"default_auto_field = 'django_mongodb_backend.fields.ObjectIdAutoField'"``. - .. step:: Create models for movie, awards, and viewer data + .. step:: Create models for movie, award, and viewer data Open the ``models.py`` file in the ``sample_mflix`` directory and replace its contents with the following code: @@ -121,6 +121,7 @@ To learn more about the ``sample_mflix`` database, see :atlas:`Sample Mflix Data ``INSTALLED_APPS`` setting to resemble the following code: .. code-block:: python + :emphasize-lines: 2 INSTALLED_APPS = [ 'sample_mflix.apps.SampleMflixConfig', diff --git a/source/get-started/install.txt b/source/get-started/install.txt index a05fb32..a3942be 100644 --- a/source/get-started/install.txt +++ b/source/get-started/install.txt @@ -63,7 +63,7 @@ in your development environment. This command also installs the following dependencies: - PyMongo version {+pymongo-version+} and its dependencies - - Latest Django {+django-version+}.x version and its dependencies + - Latest {+framework+} {+django-version+}.x version and its dependencies After you complete these steps, you have {+django-odm+} and its dependencies installed in your development environment. \ No newline at end of file diff --git a/source/get-started/next-steps.txt b/source/get-started/next-steps.txt index 022242c..7c8ed54 100644 --- a/source/get-started/next-steps.txt +++ b/source/get-started/next-steps.txt @@ -6,7 +6,7 @@ Next Steps Congratulations on completing the {+django-odm+} tutorial! -In this tutorial, you created a Django application that +In this tutorial, you created a {+framework+} application that connects to a MongoDB deployment hosted on MongoDB Atlas and interacts with data. diff --git a/source/get-started/query-data.txt b/source/get-started/query-data.txt index 3e6f8e4..75110c3 100644 --- a/source/get-started/query-data.txt +++ b/source/get-started/query-data.txt @@ -17,7 +17,7 @@ to read data from the ``sample_mflix`` database. .. procedure:: :style: connected - .. step:: Query the "users" collection for a specified email + .. step:: Query the ``users`` collection for a specified email Start a Python shell by running the following command: @@ -42,7 +42,7 @@ to read data from the ``sample_mflix`` database. - .. step:: Query the "movies" collection for specified runtime values + .. step:: Query the ``movies`` collection for specified runtime values Run the following code to query the ``sample_mflix.movies`` collection for movies that have a ``runtime`` value less than diff --git a/source/get-started/write-data.txt b/source/get-started/write-data.txt index b9e9a11..91b314e 100644 --- a/source/get-started/write-data.txt +++ b/source/get-started/write-data.txt @@ -39,7 +39,7 @@ and delete functions on your model objects. :language: python :copyable: - .. step:: Insert a movie into the database + .. step:: Insert a ``Movie`` object into the database Run the following code to create an ``Movie`` object that stores data about a movie titled ``"Minari"``, including @@ -51,7 +51,7 @@ and delete functions on your model objects. :language: python :copyable: - .. step:: Update your Movie object + .. step:: Update your ``Movie`` object The ``Movie`` object created in the previous step has inaccurate data: the ``runtime`` value is ``217``, but the correct ``runtime`` value is ``117``. @@ -64,7 +64,7 @@ and delete functions on your model objects. :language: python :copyable: - .. step:: Insert a Viewer into the database + .. step:: Insert a ``Viewer`` object into the database You can also use your ``Viewer`` model to insert documents into the ``sample_mflix.users`` collection. Run the following code to create @@ -76,7 +76,7 @@ and delete functions on your model objects. :language: python :copyable: - .. step:: Delete a Viewer object + .. step:: Delete a ``Viewer`` object One movie viewer named "Alliser Thorne" no longer uses the movie streaming site. To remove this viewer's corresponding document from the database, diff --git a/source/includes/figures/atlas_connection_connect_cluster.png b/source/includes/figures/atlas_connection_connect_cluster.png index dce8a0d..eba1fbc 100644 Binary files a/source/includes/figures/atlas_connection_connect_cluster.png and b/source/includes/figures/atlas_connection_connect_cluster.png differ diff --git a/source/includes/figures/atlas_connection_copy_string_python.png b/source/includes/figures/atlas_connection_copy_string_python.png index 7796cab..cb00eea 100644 Binary files a/source/includes/figures/atlas_connection_copy_string_python.png and b/source/includes/figures/atlas_connection_copy_string_python.png differ diff --git a/source/includes/get-started/models.py b/source/includes/get-started/models.py index 6a221cf..090a4f2 100644 --- a/source/includes/get-started/models.py +++ b/source/includes/get-started/models.py @@ -8,9 +8,6 @@ class Award(EmbeddedModel): nominations = models.IntegerField(default=0) text = models.CharField(max_length=100) - class Meta: - managed = False - class Movie(models.Model): title = models.CharField(max_length=200) plot = models.TextField(blank=True) diff --git a/source/includes/interact-data/specify-a-query.py b/source/includes/interact-data/specify-a-query.py index 4f2e0ed..643e063 100644 --- a/source/includes/interact-data/specify-a-query.py +++ b/source/includes/interact-data/specify-a-query.py @@ -8,9 +8,6 @@ class Award(EmbeddedModel): nominations = models.IntegerField(default=0) text = models.CharField(max_length=100) - class Meta: - managed = False - class Movie(models.Model): title = models.CharField(max_length=200) plot = models.TextField(blank=True) diff --git a/source/includes/model-data/models.py b/source/includes/model-data/models.py index f9fb7c7..1962fa9 100644 --- a/source/includes/model-data/models.py +++ b/source/includes/model-data/models.py @@ -66,9 +66,6 @@ class Award(EmbeddedModel): nominations = models.IntegerField(default=0) text = models.CharField(max_length=100) - class Meta: - managed = False - class Movie(models.Model): title = models.CharField(max_length=200) plot = models.TextField(blank=True) diff --git a/source/index.txt b/source/index.txt index a2aac09..ca2da46 100644 --- a/source/index.txt +++ b/source/index.txt @@ -30,7 +30,7 @@ Introduction ------------ Welcome to the documentation site for the official {+django-odm+}, -a Django database backend that uses PyMongo to connect to MongoDB. +a {+framework+} database backend that uses PyMongo to connect to MongoDB. Get Started ----------- @@ -47,7 +47,7 @@ in the :ref:`django-connection-configuration` section. Model Your Data --------------- -Learn how to create Django models that represent MongoDB collections +Learn how to create {+framework+} models that represent MongoDB collections in the :ref:`django-model-data` section. Interact with Data diff --git a/source/interact-data.txt b/source/interact-data.txt index 261ecd3..c2bc78f 100644 --- a/source/interact-data.txt +++ b/source/interact-data.txt @@ -15,7 +15,7 @@ Interact with Data :values: reference .. meta:: - :description: Learn how to use Django MongoDB Backend to interact with MongoDB data. + :description: Learn how to use {+django-odm+} to interact with MongoDB data. :keywords: odm, crud, query .. toctree:: diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index d97d5de..f0d5c26 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -41,9 +41,9 @@ to every model class. .. tip:: - To learn more about {+framework+}'s ``QuerySet`` API, see the - `QuerySet API reference `__ - in the {+framework+} documentation. + To learn more about {+framework+}'s ``QuerySet`` API, see + :py:class:`~django.db.models.query.QuerySet` in the {+framework+} + documentation. This guide shows how to use the following ``QuerySet`` methods: @@ -115,10 +115,10 @@ code: .. tip:: - To learn more about the ``create()`` method, see `create() - <{+django-docs+}/ref/models/querysets/#create>`__ in the {+framework+} + To learn more about the ``create()`` method, see + :py:meth:`~django.db.models.query.QuerySet.create` in the {+framework+} documentation. - + .. _django-crud-read: Read Documents @@ -155,10 +155,10 @@ returns ``Movie`` objects that represent movies released on January 1, 2000: .. tip:: - To learn more about the ``filter()`` method, see `filter() - <{+django-docs+}/ref/models/querysets/#filter>`__ in the {+framework+} - documentation. - + To learn more about the ``filter()`` method, see + :py:meth:`~django.db.models.query.QuerySet.filter` + in the {+framework+} documentation. + Return One Document Example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -192,9 +192,9 @@ retrieves a document in which the ``title`` value is ``"Boyhood"``: .. tip:: - To learn more about the ``get()`` method, see `get() - <{+django-docs+}/ref/models/querysets/#get>`__ in the {+framework+} - documentation. + To learn more about the ``get()`` method, see + :py:meth:`~django.db.models.query.QuerySet.get` + in the {+framework+} documentation. .. _django-crud-modify: @@ -231,9 +231,9 @@ a document that has a ``title`` value of ``"High Fidelity"`` and adds a .. tip:: - To learn more about the ``update()`` method, see `update() - <{+django-docs+}/ref/models/querysets/#update>`__ in the {+framework+} - documentation. + To learn more about the ``update()`` method, see + :py:meth:`~django.db.models.query.QuerySet.update` + in the {+framework+} documentation. .. _django-crud-delete: @@ -241,8 +241,8 @@ Delete Documents ---------------- To delete documents in a collection, call the ``filter()`` and ``delete()`` -methods on your model's ``Manager`` class. Pass a query filter, -or criteria that specifies which documents to delete, as an argument to the +methods on your model's manager, Pass a query filter, or criteria +that specifies which documents to delete, as an argument to the ``filter()`` method. Example @@ -268,14 +268,15 @@ and deletes documents that have a ``runtime`` value of ``5``: .. tip:: - To learn more about the ``delete()`` method, see `delete() - <{+django-docs+}/ref/models/querysets/#delete>`__ in the {+framework+} - documentation. + To learn more about the ``delete()`` method, see + :py:meth:`~django.db.models.query.QuerySet.delete` + in the {+framework+} documentation. Additional Information ---------------------- -.. TODO: To learn more about performing read operations, see the Specify a Query guide. +To learn more about performing read operations, see the :ref:`django-specify-query` +guide. To view more create, read, update, and delete examples, see the following steps of the :ref:`django-get-started` tutorial: diff --git a/source/interact-data/raw-queries.txt b/source/interact-data/raw-queries.txt index 970060c..7498340 100644 --- a/source/interact-data/raw-queries.txt +++ b/source/interact-data/raw-queries.txt @@ -23,13 +23,13 @@ Overview In this guide, you can learn how to use {+django-odm+} to run raw queries on your MongoDB database. Raw queries allow you to query the database by using MongoDB's aggregation pipeline syntax -rather than Django methods. You can also run queries directly +rather than {+framework+} methods. You can also run queries directly on your ``MongoClient`` object for expanded access to your MongoDB data. Query API ~~~~~~~~~ -The Django ``QuerySet`` API provides a ``raw()`` method, which allows +The {+framework+} ``QuerySet`` API provides a ``raw()`` method, which allows you to perform raw SQL queries on relational databases. However, {+django-odm+} does not support the ``raw()`` method. Instead, the ODM provides the ``raw_aggregate()`` method, which you can use to send instructions @@ -37,16 +37,16 @@ to the database in pipeline stages. .. note:: - Django provides a ``QuerySet.aggregate()`` method, which differs from the + {+framework+} provides a ``QuerySet.aggregate()`` method, which differs from the ``QuerySet.raw_aggregate()`` method. You can use ``aggregate()`` to retrieve values by aggregating a collection of model objects. To learn more about - the ``aggregate()`` method, see `Aggregation <{+django-docs+}/topics/db/aggregation/>`__ - in the Django documentation. - + the ``aggregate()`` method, see :py:meth:`~django.db.models.query.QuerySet.aggregate` + in the {+framework+} documentation. + You can run database queries by calling ``QuerySet`` methods on your model's ``Manager``. The ``Manager`` class handles database operations and allows you -to interact with your MongoDB data by referencing Django models. By default, -Django adds a ``Manager`` named ``objects`` to every model class. This default +to interact with your MongoDB data by referencing {+framework+} models. By default, +{+framework+} adds a ``Manager`` named ``objects`` to every model class. This default ``Manager`` does not support the ``raw_aggregate()`` method. To use this MongoDB-specific method, set your model's ``objects`` field to a custom manager called ``MongoManager``. @@ -57,7 +57,7 @@ Sample Data The examples in this guide use the ``Movie`` and ``Theater`` models, which represent collections in the ``sample_mflix`` database from the :atlas:`Atlas sample datasets `. These models explicitly set the ``objects`` field to use a custom ``MongoManager``, -rather than Django's default ``Manager`` class. The model classes have the following +rather than {+framework+}'s default ``Manager`` class. The model classes have the following definitions: .. literalinclude:: /includes/interact-data/raw-queries.py diff --git a/source/interact-data/specify-a-query.txt b/source/interact-data/specify-a-query.txt index 1905633..aeb74e5 100644 --- a/source/interact-data/specify-a-query.txt +++ b/source/interact-data/specify-a-query.txt @@ -47,10 +47,9 @@ cache. Future evaluations of the ``QuerySet`` use the cached results. .. tip:: - To learn more about the {+framework+} ``QuerySet`` API, see `QuerySet API reference - <{+django-docs+}/ref/models/querysets/>`__ in the {+framework+} documentation. - :py:class:`~django.db.models.query.QuerySet` - + To learn more about the {+framework+} ``QuerySet`` API, see :py:class:`~django.db.models.query.QuerySet` + in the {+framework+} documentation. + Sample Data ~~~~~~~~~~~ @@ -234,8 +233,8 @@ method allows you to specify your query criteria in a MongoDB aggregation pipeline, which you pass as an argument to ``raw_aggregate()``. -.. TODO: To learn how to run raw database queries, see the :ref:`django-raw-queries` - guide. +To learn how to run raw database queries, see the :ref:`django-raw-queries` +guide. .. _django-query-filter: @@ -741,8 +740,8 @@ provided ``KT()`` expressions. To learn more about ``KT()`` expressions and the ``annotate()`` method, see the following resources in the {+framework+} documentation: - - `KT() expressions <{+django-docs+}/topics/db/queries/#module-django.db.models.fields.json>`__ - - `annotate() <{+django-docs+}/ref/models/querysets/#django.db.models.query.QuerySet.annotate>`__ + - :py:class:`~django.db.models.fields.json.KT` + - :py:meth:`~django.db.models.query.QuerySet.annotate` The following example uses ``annotate()`` and ``KT()`` to create a new ``score`` key, which stores ``imdb.rating`` nested field values. diff --git a/source/model-data.txt b/source/model-data.txt index 4754663..0543585 100644 --- a/source/model-data.txt +++ b/source/model-data.txt @@ -15,7 +15,7 @@ Model Your Data :values: reference .. meta:: - :description: Learn how to use Django MongoDB Backend to model MongoDB data. + :description: Learn how to use {+django-odm+} to model MongoDB data. :keywords: field, collection, object, model .. toctree:: @@ -26,10 +26,10 @@ Model Your Data Create Models In this section, you can learn how to create and customize -your Django models for use with MongoDB. +your {+framework+} models for use with MongoDB. - :ref:`django-models`: Learn how to create models by using supported field - types and Django's model configuration features. + types and {+framework+}'s model configuration features. - :ref:`django-indexes`: Learn how to create indexes by modifying your model classes. diff --git a/source/model-data/indexes.txt b/source/model-data/indexes.txt index d4ea144..d092f22 100644 --- a/source/model-data/indexes.txt +++ b/source/model-data/indexes.txt @@ -21,7 +21,7 @@ Overview -------- In this guide, you can learn how to create MongoDB **indexes** by using your -Django models. Indexes can improve the efficiency of queries and provide +{+framework+} models. Indexes can improve the efficiency of queries and provide additional query and document storage functionality. Without indexes, MongoDB must scan every document in a collection to find the @@ -30,15 +30,14 @@ negatively affect the performance of your application. However, if an appropriate index exists for a query, MongoDB can use the index to limit the documents it inspects. -Django provides the ``Index`` class, which you can use to create an +{+framework+} provides the ``Index`` class, which you can use to create an index on your model. {+django-odm+} creates the same index on your MongoDB collection that the model represents. .. tip:: - To learn more about the ``Index`` class, see `Model index reference - <{+django-docs+}/ref/models/indexes/>`__ in the Django - documentation. + To learn more about the ``Index`` class, see :py:class:`~django.db.models.Index` + in the {+framework+} documentation. Sample Data ~~~~~~~~~~~ @@ -55,7 +54,7 @@ These model classes have the following definitions: In the ``Recipe`` model's ``Meta`` class, the ``db_table = "recipes"`` option instructs {+django-odm+} to map the ``Recipe`` model to a MongoDB collection -called ``recipes``. To learn how to create a Django application that +called ``recipes``. To learn how to create a {+framework+} application that uses models to interact with MongoDB collections, visit the :ref:`django-get-started` tutorial. @@ -81,7 +80,7 @@ To define your index, pass the following arguments to the ``models.Index()`` met - ``fields``: Specifies a list of fields to index. This argument is required. -- ``name``: Specifies the index name. This argument is optional, and Django +- ``name``: Specifies the index name. This argument is optional, and {+framework+} automatically creates an index name if you don't provide one. - ``condition``: Specifies a subset of documents to index. This argument is @@ -94,7 +93,7 @@ same indexes on the MongoDB collection. .. tip:: To learn how to create and apply database migrations, see `Migrations - <{+django-docs+}/topics/migrations/>`__ in the Django documentation. + <{+django-docs+}/topics/migrations/>`__ in the {+framework+} documentation. This section shows how to create the following index types: @@ -221,9 +220,8 @@ argument to ``models.Index()``. .. tip:: - To learn more about ``Q`` objects, see `Complex lookups with Q objects - <{+django-docs+}/topics/db/queries/#complex-lookups-with-q-objects>`__ - in the Django documentation. + To learn more about ``Q`` objects, see :py:class:`~django.db.models.Q` + in the {+framework+} documentation. The following example updates the ``Recipe`` model's ``Meta`` class to create a partial index on the ``cuisine`` field, instructing {+django-odm+} to @@ -283,7 +281,7 @@ creates a unique compound index on these fields: Setting the ``constraints`` option to a ``UniqueConstraint`` automatically creates an index on the specified fields. To learn more about the ``Meta`` class's ``constraint`` option, see `Constraints <{+django-docs+}/ref/models/constraints/>`__ - in the Django documentation. + in the {+framework+} documentation. Additional Information ---------------------- @@ -298,6 +296,6 @@ see the following {+mdb-server+} manual resources: - :manual:`Partial Indexes ` - :manual:`Unique Indexes ` -To learn more about creating indexes on Django models, see -`Model index reference <{+django-docs+}/ref/models/indexes/>`__ in the Django +To learn more about creating indexes on {+framework+} models, see +:py:class:`~django.db.models.Index` in the {+framework+} documentation. diff --git a/source/model-data/models.txt b/source/model-data/models.txt index 61729a1..5c20703 100644 --- a/source/model-data/models.txt +++ b/source/model-data/models.txt @@ -28,9 +28,8 @@ documents by using model objects. .. tip:: - To learn more about {+framework+} models, see `Models - <{+django-docs+}/topics/db/models/>`__ in the {+framework+} - documentation. + To learn more about {+framework+} models, see :py:class:`~django.db.models.Model` + in the {+framework+} documentation. .. _django-models-fields: @@ -87,8 +86,7 @@ that {+django-odm+} supports: Python ``timedelta`` instances. * - ``EmailField`` - - | Stores ``CharField`` values and uses an `EmailValidator - <{+django-docs+}/ref/validators/#django.core.validators.EmailValidator>`__ + - | Stores ``CharField`` values and uses an :py:class:`~django.core.validators.EmailValidator` to verify that the value is an email address. * - ``FileField`` @@ -103,6 +101,10 @@ that {+django-odm+} supports: * - ``GenericIPAddressField`` - | Stores an IPv4 or IPv6 address in string format. + * - ``ImageField`` + - | Stores a ``FileField`` value and verifies that the uploaded object + is a valid image. + * - ``IntegerField`` - | Stores integer values up to 32 bits in size. @@ -149,7 +151,7 @@ called BSON that allows for flexible data processing. manual. The following table describes supported BSON field types and their -{+django-odm+} equivalents that you can use in your Django models: +{+django-odm+} equivalents that you can use in your {+framework+} models: .. list-table:: :header-rows: 1 @@ -371,11 +373,11 @@ and pass the following arguments: stored in the array. You cannot specify ``EmbeddedModelField`` or ``FileField`` as the base field type. -- ``size``: Specifies the maximum size of the array. This field is - optional. +- ``size``: *(Optional)* Specifies the maximum size of the array. -- ``options``: Specifies Django field options. To view a list of - available options, see `Field options <{+django-docs+}/ref/models/fields/#field-options>`__ +- ``options``: *(Optional)* Specifies {+framework+} field options. + To view a list of available options, see `Field options + <{+django-docs+}/ref/models/fields/#field-options>`__ in the {+framework+} documentation. .. tip:: @@ -412,18 +414,20 @@ Use an EmbeddedModelField You can use an ``EmbeddedModelField`` to represent a MongoDB ``Object``, which stores a nested document value. This type allows one model to -store a separate model in one of its fields. To create an ``EmbeddedModelField``, use -the ``EmbeddedModelField()`` class constructor and pass the following arguments: +store a separate model in one of its fields. To create an ``EmbeddedModelField``, +define an embedded model class as a subclass of the ``EmbeddedModel`` abstract model. +Then, create a field in your base model class by using the ``EmbeddedModelField()`` +constructor and pass the following arguments: - ``embedded_model``: Specifies the model class to store. -- ``options``: Specifies Django field options. To view a list of +- ``options``: *(Optional)* Specifies {+framework+} field options. To view a list of available options, see `Field options <{+django-docs+}/ref/models/fields/#field-options>`__ in the {+framework+} documentation. .. important:: - The ``makemigrations`` Django command does not detect changes to embedded + The ``makemigrations`` {+framework+} command does not detect changes to embedded models. If you make changes to the embedded model's class, the model stored in the ``EmbeddedModelField`` does not reflect the changes. @@ -441,7 +445,7 @@ and modifies the ``Movie`` model to include the ``EmbeddedModelField``: :end-before: end-embedded-field :language: python :copyable: - :emphasize-lines: 18 + :emphasize-lines: 5, 15 .. tip:: @@ -452,8 +456,8 @@ Additional Information ---------------------- To learn how to use your models to run database operations, -see the :ref:`interact-data` guides. +see the :ref:`django-interact-data` guides. -To learn more about {+framework+} field types, see `Model index reference -<{+django-docs+}/ref/models/fields/>`__ in the {+framework+} -documentation. \ No newline at end of file +To learn more about {+framework+} field types, see the +`Model field reference <{+django-docs+}/ref/models/fields/>`__ +in the {+framework+} documentation. \ No newline at end of file