From 42303725ffd9ce3b1597041d73375f646e56422e Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 10 Jan 2025 17:16:36 -0500 Subject: [PATCH 01/23] DOCSP-46321: CRUD operations --- source/interact-data/crud.txt | 230 ++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 source/interact-data/crud.txt diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt new file mode 100644 index 00000000..8f72f88e --- /dev/null +++ b/source/interact-data/crud.txt @@ -0,0 +1,230 @@ +.. _django-crud: + +======================= +Perform CRUD Operations +======================= + +.. contents:: On this page + :local: + :backlinks: none + :depth: 2 + :class: singlecol + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: insert, modify, read, write, code example + +Overview +--------- + +In this guide, you can learn how to use {+django-odm+} to run +create, read, update, and delete (CRUD) operations on your MongoDB +database. + +You can use methods provided by the Django ``QuerySet`` API to run +CRUD operations. This guide shows how to use the following ``QuerySet`` +methods: + +- :ref:`create() ` +- :ref:`filter() ` +- :ref:`update() ` +- :ref:`delete() ` + +.. tip:: + + To learn more about Django's ``QuerySet`` API, see + `QuerySet API reference `__ + in the Django documentation. + +Sample Data +~~~~~~~~~~~ + +The examples in this guide use the ``Movie`` model, which represents +the ``sample_mflix.movies`` collection from the :atlas:`Atlas sample datasets `. +The ``Movie`` model class has the following definition: + +.. code-block:: python + + from django.db import models + from django_mongodb_backend.fields import EmbeddedModelField, ArrayField + from django_mongodb_backend.managers import MongoManager + + class Movie(models.Model): + title = models.CharField(max_length=200) + plot = models.TextField(null=True) + runtime = models.IntegerField(default=0) + released = models.DateTimeField("release date", null=True) + awards = EmbeddedModelField(Award) + genres = ArrayField(models.CharField(max_length=100), blank=True) + objects = MongoManager() + + class Meta: + db_table = "movies" + + def __str__(self): + return self.title + +To learn how to create a Django application that uses the ``Movie`` +model to interact with MongoDB documents, visit the :ref:`django-get-started` +tutorial. + +.. _django-crud-insert: + +Insert Documents +---------------- + +To insert a document into a collection, call the ``create()`` method on your +model objects that represent the collection. Pass the new document's fields +and values as arguments to the ``create()`` method. + +Example +``````` + +The following example calls the ``create()`` method on your ``Movie`` objects +to insert a document into the ``sample_mflix.movies`` collection. The new +document has a ``title`` value of ``"Poor Things"`` and a ``runtime`` value +of ``141``: + +.. code-block:: python + + from sample_mflix.models import Movie + + movie = Movie.objects.create(title="Poor Things", runtime=141) + +.. note:: + + The ``create()`` method allows you to create a new ``Movie`` object + and save the object as a collection document in one method call. + To view an example that creates an object then saves it to the + database by calling ``save()``, see the :ref:`django-get-started-write` + step of the Getting Started tutorial. + +.. _django-crud-read: + +Read Documents +-------------- + +To retrieve documents from your collection, call the ``filter()`` method on your +model objects that represent the collection. Pass a query filter, or criteria +that specifies which documents to retrieve, as an argument to the ``filter()`` method. + +Alternatively, you can call the ``get()`` method to retrieve a single document +that matches your query. + +.. TODO: (add to the previous paragraph) To view an example that calls the + ``get()`` method, see the Specify a Query guide. + +Example +``````` + +The following example calls the ``filter()`` method on your ``Movie`` objects +to retrieve documents from the ``sample_mflix.movies`` collection. The query +returns ``Movie`` objects that represent movies released on January 1, 2000: + +.. io-code-block:: + :copyable: true + + .. input:: + :language: python + + from sample_mflix.models import Movie + from django.utils import timezone + from datetime import datetime + + Movie.objects.filter(released=timezone.make_aware(datetime(2000, 1, 1, 0, 0), + timezone.get_current_timezone())) + + .. output:: + :language: none + :visible: false + + , , + , , , + ]> + + +.. _django-crud-modify: + +Modify Documents +---------------- + +To modify documents in a collection, call the ``filter()`` and ``update()`` +methods on your model objects that represent the collection. Pass a query filter, +or criteria that specifies which documents to update, as an argument to the +``filter()`` method. Then, pass the fields and values you want to update as +arguments to the ``update()`` method. + +Example +``````` + +The following example calls the ``update()`` method on your ``Movie`` objects +to modify documents in the ``sample_mflix.movies`` collection. The code matches +a document that has a ``title`` value of ``"High Fidelity"`` and adds a +``plot`` field: + +.. io-code-block:: + :copyable: true + + .. input:: + :language: python + + from sample_mflix.models import Movie + + Movie.objects.filter(title="High Fidelity").update(plot= + "Rob, a record store owner and compulsive list maker, recounts his top five breakups, including the one in progress.") + + .. output:: + :language: none + :visible: false + + // Outputs the number of modified documents + 1 + +.. _django-crud-delete: + +Delete Documents +---------------- + +To delete documents in a collection, call the ``filter()`` and ``delete()`` +methods on your model objects that represent the collection. Pass a query filter, +or criteria that specifies which documents to delete, as an argument to the +``filter()`` method. + +Example +``````` + +The following example calls the ``delete()`` method on your ``Movie`` objects +to delete documents in the ``sample_mflix.movies`` collection. The code matches +and deletes documents that have a ``runtime`` value of ``5``: + +.. io-code-block:: + :copyable: true + + .. input:: + :language: python + + from sample_mflix.models import Movie + + Movie.objects.filter(runtime=5).delete() + + .. output:: + :language: none + :visible: false + + // Outputs the number of deleted documents and objects + 16 + + +Additional Information +---------------------- + +.. TODO: To learn more about performing read operations, see the Specify a Query guide. + +To view more create, read, update, and delete examples, see the following +steps of the :ref:`django-get-started` tutorial: + +- :ref:`django-get-started-write` +- :ref:`django-get-started-read` \ No newline at end of file From 924788d61307ad147b96183c4cff6de0467ca3f0 Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 10 Jan 2025 17:31:17 -0500 Subject: [PATCH 02/23] edits --- source/interact-data/crud.txt | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 8f72f88e..bb70157d 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -39,6 +39,11 @@ methods: `QuerySet API reference `__ in the Django documentation. +You can also use the Django admin site to edit your models +and their corresponding collections on a web interface. For +more information, see `The Django admin site `__ +in the Django documentation. + Sample Data ~~~~~~~~~~~ @@ -67,9 +72,17 @@ The ``Movie`` model class has the following definition: def __str__(self): return self.title +You can use the Python interactive shell to run the code examples. +To enter the shell, run the following command from your project's +root directory: + +.. code-block:: bash + + python3 manage.py shell + To learn how to create a Django application that uses the ``Movie`` -model to interact with MongoDB documents, visit the :ref:`django-get-started` -tutorial. +model and the Python interactive shell to interact with MongoDB documents, +visit the :ref:`django-get-started` tutorial. .. _django-crud-insert: @@ -81,7 +94,7 @@ model objects that represent the collection. Pass the new document's fields and values as arguments to the ``create()`` method. Example -``````` +~~~~~~~ The following example calls the ``create()`` method on your ``Movie`` objects to insert a document into the ``sample_mflix.movies`` collection. The new @@ -90,9 +103,9 @@ of ``141``: .. code-block:: python - from sample_mflix.models import Movie + from sample_mflix.models import Movie - movie = Movie.objects.create(title="Poor Things", runtime=141) + movie = Movie.objects.create(title="Poor Things", runtime=141) .. note:: @@ -118,7 +131,7 @@ that matches your query. ``get()`` method, see the Specify a Query guide. Example -``````` +~~~~~~~ The following example calls the ``filter()`` method on your ``Movie`` objects to retrieve documents from the ``sample_mflix.movies`` collection. The query @@ -158,7 +171,7 @@ or criteria that specifies which documents to update, as an argument to the arguments to the ``update()`` method. Example -``````` +~~~~~~~ The following example calls the ``update()`` method on your ``Movie`` objects to modify documents in the ``sample_mflix.movies`` collection. The code matches @@ -194,7 +207,7 @@ or criteria that specifies which documents to delete, as an argument to the ``filter()`` method. Example -``````` +~~~~~~~ The following example calls the ``delete()`` method on your ``Movie`` objects to delete documents in the ``sample_mflix.movies`` collection. The code matches @@ -215,7 +228,7 @@ and deletes documents that have a ``runtime`` value of ``5``: :visible: false // Outputs the number of deleted documents and objects - 16 + (16, {'sample_mflix.Movie': 16}) Additional Information @@ -227,4 +240,4 @@ To view more create, read, update, and delete examples, see the following steps of the :ref:`django-get-started` tutorial: - :ref:`django-get-started-write` -- :ref:`django-get-started-read` \ No newline at end of file +- :ref:`django-get-started-query` \ No newline at end of file From 61237206bdec04f25f9bad0d80f09cb95bfd1caa Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 10 Jan 2025 17:31:47 -0500 Subject: [PATCH 03/23] snooty --- snooty.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/snooty.toml b/snooty.toml index de16c44e..eead367f 100644 --- a/snooty.toml +++ b/snooty.toml @@ -25,6 +25,7 @@ sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/" driver-short = "PyMongo" driver-long = "PyMongo, the MongoDB synchronous Python driver," driver-async = "PyMongo Async" +django-odm = "MongoDB Backend for Django" language = "Python" mdb-server = "MongoDB Server" mongo-community = "MongoDB Community Edition" From 84bc4868dfce7b6d36a093c024d7d81cd008a5a3 Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 10 Jan 2025 17:45:10 -0500 Subject: [PATCH 04/23] add get() example --- source/interact-data/crud.txt | 37 +++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index bb70157d..be10d274 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -29,7 +29,7 @@ CRUD operations. This guide shows how to use the following ``QuerySet`` methods: - :ref:`create() ` -- :ref:`filter() ` +- :ref:`filter() and get() ` - :ref:`update() ` - :ref:`delete() ` @@ -127,11 +127,8 @@ that specifies which documents to retrieve, as an argument to the ``filter()`` m Alternatively, you can call the ``get()`` method to retrieve a single document that matches your query. -.. TODO: (add to the previous paragraph) To view an example that calls the - ``get()`` method, see the Specify a Query guide. - -Example -~~~~~~~ +Return Multiple Documents Example +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The following example calls the ``filter()`` method on your ``Movie`` objects to retrieve documents from the ``sample_mflix.movies`` collection. The query @@ -158,6 +155,34 @@ returns ``Movie`` objects that represent movies released on January 1, 2000: , , , ]> +Return One Document Example +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To retrieve only one document that matches your query criteria, call the +``get()`` method and pass a query filter as an argument. The following example +retrieves a document in which the ``title`` value is ``"Boyhood"``: + +.. io-code-block:: + :copyable: true + + .. input:: + :language: python + + from sample_mflix.models import Movie + + Movie.objects.get(title="Boyhood") + + .. output:: + :language: none + :visible: false + + + +.. note:: + + If your query matches no documents or multiple documents, the ``get()`` + method generates an error. To retrieve one document from a query + that might match multiple, chain the ``first()`` method to ``filter()``. .. _django-crud-modify: From b81892bf0c39cb2a4b56d1ac4a464ab4c90b30d9 Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 10 Jan 2025 17:50:21 -0500 Subject: [PATCH 05/23] more info --- source/interact-data/crud.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index be10d274..d537e0c5 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -22,11 +22,13 @@ Overview In this guide, you can learn how to use {+django-odm+} to run create, read, update, and delete (CRUD) operations on your MongoDB -database. +collection. You can use methods provided by the Django ``QuerySet`` API to run -CRUD operations. This guide shows how to use the following ``QuerySet`` -methods: +CRUD operations. To update documents in your collection, call the +``QuerySet`` operation methods on your model objects that represent the collection. +Then, {+django-odm+} runs the operations on your collection documents. +This guide shows how to use the following ``QuerySet`` methods: - :ref:`create() ` - :ref:`filter() and get() ` From 158ff3dd3615fdccefe23f9035751cd39c6e7ab8 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 14 Jan 2025 10:56:45 -0500 Subject: [PATCH 06/23] feedback --- snooty.toml | 2 +- source/interact-data/crud.txt | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/snooty.toml b/snooty.toml index eead367f..1f5fb267 100644 --- a/snooty.toml +++ b/snooty.toml @@ -25,7 +25,7 @@ sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/" driver-short = "PyMongo" driver-long = "PyMongo, the MongoDB synchronous Python driver," driver-async = "PyMongo Async" -django-odm = "MongoDB Backend for Django" +django-odm = "Django MongoDB Backend" language = "Python" mdb-server = "MongoDB Server" mongo-community = "MongoDB Community Edition" diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index d537e0c5..38bbc923 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -59,20 +59,21 @@ The ``Movie`` model class has the following definition: from django_mongodb_backend.fields import EmbeddedModelField, ArrayField from django_mongodb_backend.managers import MongoManager - class Movie(models.Model): - title = models.CharField(max_length=200) - plot = models.TextField(null=True) - runtime = models.IntegerField(default=0) - released = models.DateTimeField("release date", null=True) - awards = EmbeddedModelField(Award) - genres = ArrayField(models.CharField(max_length=100), blank=True) - objects = MongoManager() - - class Meta: - db_table = "movies" - - def __str__(self): - return self.title + class Movie(models.Model): + title = models.CharField(max_length=200) + plot = models.TextField(blank=True) + runtime = models.IntegerField(default=0) + released = models.DateTimeField("release date", null=True, blank=True) + awards = EmbeddedModelField(Award) + genres = ArrayField(models.CharField(max_length=100), null=True, blank=True) + objects = MongoManager() + + class Meta: + db_table = "movies" + managed = False + + def __str__(self): + return self.title You can use the Python interactive shell to run the code examples. To enter the shell, run the following command from your project's @@ -80,7 +81,7 @@ root directory: .. code-block:: bash - python3 manage.py shell + python manage.py shell To learn how to create a Django application that uses the ``Movie`` model and the Python interactive shell to interact with MongoDB documents, From da3ac8c7d5a633d7812cc419d4980f204983d5dc Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 14 Jan 2025 11:00:12 -0500 Subject: [PATCH 07/23] edits --- source/interact-data/crud.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 38bbc923..17ec7e38 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -115,8 +115,8 @@ of ``141``: The ``create()`` method allows you to create a new ``Movie`` object and save the object as a collection document in one method call. To view an example that creates an object then saves it to the - database by calling ``save()``, see the :ref:`django-get-started-write` - step of the Getting Started tutorial. + database by calling ``save()``, see `create() `__ + in the Django documentation. .. _django-crud-read: @@ -147,8 +147,7 @@ returns ``Movie`` objects that represent movies released on January 1, 2000: from django.utils import timezone from datetime import datetime - Movie.objects.filter(released=timezone.make_aware(datetime(2000, 1, 1, 0, 0), - timezone.get_current_timezone())) + Movie.objects.filter(released=timezone.make_aware(datetime(2000, 1, 1))) .. output:: :language: none From 15fee185381056552f04c72d7004295ecf3cbb55 Mon Sep 17 00:00:00 2001 From: norareidy Date: Wed, 15 Jan 2025 16:17:55 -0500 Subject: [PATCH 08/23] feedback --- source/interact-data/crud.txt | 52 +++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 17ec7e38..ddfeab2d 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -25,9 +25,12 @@ create, read, update, and delete (CRUD) operations on your MongoDB collection. You can use methods provided by the Django ``QuerySet`` API to run -CRUD operations. To update documents in your collection, call the -``QuerySet`` operation methods on your model objects that represent the collection. -Then, {+django-odm+} runs the operations on your collection documents. +CRUD operations. To run these operations, call ``QuerySet`` methods +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 guide shows how to use the following ``QuerySet`` methods: - :ref:`create() ` @@ -57,7 +60,6 @@ The ``Movie`` model class has the following definition: from django.db import models from django_mongodb_backend.fields import EmbeddedModelField, ArrayField - from django_mongodb_backend.managers import MongoManager class Movie(models.Model): title = models.CharField(max_length=200) @@ -66,7 +68,6 @@ The ``Movie`` model class has the following definition: released = models.DateTimeField("release date", null=True, blank=True) awards = EmbeddedModelField(Award) genres = ArrayField(models.CharField(max_length=100), null=True, blank=True) - objects = MongoManager() class Meta: db_table = "movies" @@ -83,6 +84,15 @@ root directory: python manage.py shell +After entering the Python shell, ensure that you import the following models and +modules: + +.. code-block:: python + + from .models import Movie + from django.utils import timezone + from datetime import datetime + To learn how to create a Django application that uses the ``Movie`` model and the Python interactive shell to interact with MongoDB documents, visit the :ref:`django-get-started` tutorial. @@ -92,16 +102,16 @@ visit the :ref:`django-get-started` tutorial. Insert Documents ---------------- -To insert a document into a collection, call the ``create()`` method on your -model objects that represent the collection. Pass the new document's fields -and values as arguments to the ``create()`` method. +To insert a document into a collection, call the ``create()`` method +on an instance of your model's ``Manager`` class. Pass the new document's +fields and values as arguments to the ``create()`` method. Example ~~~~~~~ -The following example calls the ``create()`` method on your ``Movie`` objects -to insert a document into the ``sample_mflix.movies`` collection. The new -document has a ``title`` value of ``"Poor Things"`` and a ``runtime`` value +The following example calls the ``create()`` method to insert a document +into the ``sample_mflix.movies`` collection. The new document has +a ``title`` value of ``"Poor Things"`` and a ``runtime`` value of ``141``: .. code-block:: python @@ -123,8 +133,8 @@ of ``141``: Read Documents -------------- -To retrieve documents from your collection, call the ``filter()`` method on your -model objects that represent the collection. Pass a query filter, or criteria +To retrieve documents from your collection, call the ``filter()`` method on an +instance of your model's ``Manager`` class. Pass a query filter, or criteria that specifies which documents to retrieve, as an argument to the ``filter()`` method. Alternatively, you can call the ``get()`` method to retrieve a single document @@ -133,8 +143,8 @@ that matches your query. Return Multiple Documents Example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The following example calls the ``filter()`` method on your ``Movie`` objects -to retrieve documents from the ``sample_mflix.movies`` collection. The query +The following example calls the ``filter()`` method to retrieve +documents from the ``sample_mflix.movies`` collection. The query returns ``Movie`` objects that represent movies released on January 1, 2000: .. io-code-block:: @@ -192,7 +202,7 @@ Modify Documents ---------------- To modify documents in a collection, call the ``filter()`` and ``update()`` -methods on your model objects that represent the collection. Pass a query filter, +methods on an instance of your model's ``Manager`` class. Pass a query filter, or criteria that specifies which documents to update, as an argument to the ``filter()`` method. Then, pass the fields and values you want to update as arguments to the ``update()`` method. @@ -200,8 +210,8 @@ arguments to the ``update()`` method. Example ~~~~~~~ -The following example calls the ``update()`` method on your ``Movie`` objects -to modify documents in the ``sample_mflix.movies`` collection. The code matches +The following example calls the ``update()`` method to modify +documents in the ``sample_mflix.movies`` collection. The code matches a document that has a ``title`` value of ``"High Fidelity"`` and adds a ``plot`` field: @@ -229,15 +239,15 @@ Delete Documents ---------------- To delete documents in a collection, call the ``filter()`` and ``delete()`` -methods on your model objects that represent the collection. Pass a query filter, +methods on an instance of your model's ``Manager`` class. Pass a query filter, or criteria that specifies which documents to delete, as an argument to the ``filter()`` method. Example ~~~~~~~ -The following example calls the ``delete()`` method on your ``Movie`` objects -to delete documents in the ``sample_mflix.movies`` collection. The code matches +The following example calls the ``delete()`` method to delete documents +in the ``sample_mflix.movies`` collection. The code matches and deletes documents that have a ``runtime`` value of ``5``: .. io-code-block:: From ce6bcc40232b15efe04d1b99e6a51f3aa6b3cc36 Mon Sep 17 00:00:00 2001 From: norareidy Date: Wed, 15 Jan 2025 16:18:31 -0500 Subject: [PATCH 09/23] fix --- source/interact-data/crud.txt | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index ddfeab2d..f18dfa37 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -116,8 +116,6 @@ of ``141``: .. code-block:: python - from sample_mflix.models import Movie - movie = Movie.objects.create(title="Poor Things", runtime=141) .. note:: @@ -153,10 +151,6 @@ returns ``Movie`` objects that represent movies released on January 1, 2000: .. input:: :language: python - from sample_mflix.models import Movie - from django.utils import timezone - from datetime import datetime - Movie.objects.filter(released=timezone.make_aware(datetime(2000, 1, 1))) .. output:: @@ -180,8 +174,6 @@ retrieves a document in which the ``title`` value is ``"Boyhood"``: .. input:: :language: python - from sample_mflix.models import Movie - Movie.objects.get(title="Boyhood") .. output:: @@ -221,8 +213,6 @@ a document that has a ``title`` value of ``"High Fidelity"`` and adds a .. input:: :language: python - from sample_mflix.models import Movie - Movie.objects.filter(title="High Fidelity").update(plot= "Rob, a record store owner and compulsive list maker, recounts his top five breakups, including the one in progress.") @@ -256,8 +246,6 @@ and deletes documents that have a ``runtime`` value of ``5``: .. input:: :language: python - from sample_mflix.models import Movie - Movie.objects.filter(runtime=5).delete() .. output:: From 1283d40da829166a674b1dfc499b5772aca12d1f Mon Sep 17 00:00:00 2001 From: norareidy Date: Wed, 15 Jan 2025 16:27:59 -0500 Subject: [PATCH 10/23] AC feedback --- source/interact-data/crud.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index f18dfa37..0d3c613c 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -25,8 +25,8 @@ create, read, update, and delete (CRUD) operations on your MongoDB collection. You can use methods provided by the Django ``QuerySet`` API to run -CRUD operations. To run these operations, call ``QuerySet`` methods -your model's ``Manager``. The ``Manager`` class handles database +CRUD operations. To run these operations, you can call ``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. From 073c29c9e1181995aa94716490438c965c3d76bd Mon Sep 17 00:00:00 2001 From: norareidy Date: Wed, 15 Jan 2025 16:31:09 -0500 Subject: [PATCH 11/23] output fix --- source/interact-data/crud.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 0d3c613c..df61bee7 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -157,7 +157,7 @@ returns ``Movie`` objects that represent movies released on January 1, 2000: :language: none :visible: false - , , + , , , , , ]> From 3861026ed550e053fd4448e395d1492fb5eca0a1 Mon Sep 17 00:00:00 2001 From: norareidy Date: Thu, 16 Jan 2025 10:30:12 -0500 Subject: [PATCH 12/23] AC feedback --- source/interact-data/crud.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index df61bee7..c86fcfea 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -102,9 +102,9 @@ visit the :ref:`django-get-started` tutorial. Insert Documents ---------------- -To insert a document into a collection, call the ``create()`` method -on an instance of your model's ``Manager`` class. Pass the new document's -fields and values as arguments to the ``create()`` method. +To insert a document into a collection, call the ``create()`` method on your +model's ``Manager`` class. Pass the new document's field names and field values +as arguments to the ``create()`` method. Example ~~~~~~~ @@ -131,8 +131,8 @@ of ``141``: Read Documents -------------- -To retrieve documents from your collection, call the ``filter()`` method on an -instance of your model's ``Manager`` class. Pass a query filter, or criteria +To retrieve documents from your collection, call the ``filter()`` method +on your model's ``Manager`` class. Pass a query filter, or criteria that specifies which documents to retrieve, as an argument to the ``filter()`` method. Alternatively, you can call the ``get()`` method to retrieve a single document @@ -194,7 +194,7 @@ Modify Documents ---------------- To modify documents in a collection, call the ``filter()`` and ``update()`` -methods on an instance of your model's ``Manager`` class. Pass a query filter, +methods on your model's ``Manager`` class. Pass a query filter, or criteria that specifies which documents to update, as an argument to the ``filter()`` method. Then, pass the fields and values you want to update as arguments to the ``update()`` method. @@ -229,7 +229,7 @@ Delete Documents ---------------- To delete documents in a collection, call the ``filter()`` and ``delete()`` -methods on an instance of your model's ``Manager`` class. Pass a query filter, +methods on your model's ``Manager`` class. Pass a query filter, or criteria that specifies which documents to delete, as an argument to the ``filter()`` method. From 9c34109666dde2b4426407e3f58f5c593b098b05 Mon Sep 17 00:00:00 2001 From: norareidy Date: Thu, 16 Jan 2025 16:56:43 -0500 Subject: [PATCH 13/23] wording --- source/interact-data/crud.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index c86fcfea..333453bb 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -182,12 +182,15 @@ retrieves a document in which the ``title`` value is ``"Boyhood"``: -.. note:: +.. important:: If your query matches no documents or multiple documents, the ``get()`` method generates an error. To retrieve one document from a query that might match multiple, chain the ``first()`` method to ``filter()``. +.. TODO: To view an example that uses the ``first()`` method, see + :ref:`` in the Specify a Query guide. + .. _django-crud-modify: Modify Documents From 13fbf87563a3464cd78bc531701f36809493e2ec Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 17 Jan 2025 10:27:41 -0500 Subject: [PATCH 14/23] RR feedback --- snooty.toml | 1 + source/interact-data/crud.txt | 55 ++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/snooty.toml b/snooty.toml index 1f5fb267..ad8f4526 100644 --- a/snooty.toml +++ b/snooty.toml @@ -26,6 +26,7 @@ driver-short = "PyMongo" driver-long = "PyMongo, the MongoDB synchronous Python driver," driver-async = "PyMongo Async" django-odm = "Django MongoDB Backend" +framework = "Django" language = "Python" mdb-server = "MongoDB Server" mongo-community = "MongoDB Community Edition" diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 333453bb..a919f652 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -24,30 +24,30 @@ In this guide, you can learn how to use {+django-odm+} to run create, read, update, and delete (CRUD) operations on your MongoDB collection. -You can use methods provided by the Django ``QuerySet`` API to run +You can use methods provided by the {+framework+} ``QuerySet`` API to run CRUD operations. To run these operations, you can call ``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`` +Django models. By default, {+framework+} adds a ``Manager`` named ``objects`` to every model class. This guide shows how to use the following ``QuerySet`` methods: -- :ref:`create() ` -- :ref:`filter() and get() ` -- :ref:`update() ` -- :ref:`delete() ` +- :ref:`create() `: Inserts documents into the collection +- :ref:`filter() and get() `: Retrieves one or multiple collection documents +- :ref:`update() `: Modifies collection documents +- :ref:`delete() `: Deletes collection documents .. tip:: - To learn more about Django's ``QuerySet`` API, see + To learn more about {+framework+}'s ``QuerySet`` API, see the `QuerySet API reference `__ - in the Django documentation. + in the {+framework+} documentation. -You can also use the Django admin site to edit your models +You can also use the {+framework+} admin site to edit your models and their corresponding collections on a web interface. For -more information, see `The Django admin site `__ -in the Django documentation. +more information, see the `Django Admin Site `__ +entry in the {+framework+} documentation. Sample Data ~~~~~~~~~~~ @@ -90,10 +90,10 @@ modules: .. code-block:: python from .models import Movie - from django.utils import timezone + from {+framework+}.utils import timezone from datetime import datetime -To learn how to create a Django application that uses the ``Movie`` +To learn how to create a {+framework+} application that uses the ``Movie`` model and the Python interactive shell to interact with MongoDB documents, visit the :ref:`django-get-started` tutorial. @@ -118,13 +118,15 @@ of ``141``: movie = Movie.objects.create(title="Poor Things", runtime=141) -.. note:: +The ``create()`` method allows you to create a new ``Movie`` object +and save the object to MongoDB in one method call. Alternatively, you +can create a Movie object and call save(), as shown in the following +code: - The ``create()`` method allows you to create a new ``Movie`` object - and save the object as a collection document in one method call. - To view an example that creates an object then saves it to the - database by calling ``save()``, see `create() `__ - in the Django documentation. +.. code-block:: python + + movie = Movie(title="Poor Things", runtime=141) + movie.save() .. _django-crud-read: @@ -186,9 +188,14 @@ retrieves a document in which the ``title`` value is ``"Boyhood"``: If your query matches no documents or multiple documents, the ``get()`` method generates an error. To retrieve one document from a query - that might match multiple, chain the ``first()`` method to ``filter()``. + that might match multiple, chain the ``first()`` method to ``filter()``, + as shown in the following code: + + .. code-block:: python -.. TODO: To view an example that uses the ``first()`` method, see + Movie.objects.filter(title="Boyhood").first() + +.. TODO: To learn more about the ``first()`` method, see :ref:`` in the Specify a Query guide. .. _django-crud-modify: @@ -216,9 +223,9 @@ a document that has a ``title`` value of ``"High Fidelity"`` and adds a .. input:: :language: python - Movie.objects.filter(title="High Fidelity").update(plot= - "Rob, a record store owner and compulsive list maker, recounts his top five breakups, including the one in progress.") - + Movie.objects.filter( + title="High Fidelity").update( + plot="Rob, a record store owner, recounts his top five breakups,including the one in progress.") .. output:: :language: none :visible: false From b3bfeb8c6073d6965e12e14645da6a451bdb15ca Mon Sep 17 00:00:00 2001 From: norareidy Date: Fri, 17 Jan 2025 11:01:27 -0500 Subject: [PATCH 15/23] fix --- source/interact-data/crud.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index a919f652..78e9dc13 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -120,7 +120,7 @@ of ``141``: The ``create()`` method allows you to create a new ``Movie`` object and save the object to MongoDB in one method call. Alternatively, you -can create a Movie object and call save(), as shown in the following +can create a ``Movie`` object and call ``save()``, as shown in the following code: .. code-block:: python From 5ba56dc19f56465b45370de21ea96770fd597995 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 21 Jan 2025 18:16:42 -0500 Subject: [PATCH 16/23] feedback --- source/interact-data/crud.txt | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 78e9dc13..0f1e9924 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -26,7 +26,7 @@ collection. You can use methods provided by the {+framework+} ``QuerySet`` API to run CRUD operations. To run these operations, you can call ``QuerySet`` methods -on your model's ``Manager``. The ``Manager`` class handles database +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, {+framework+} adds a ``Manager`` named ``objects`` to every model class. @@ -76,6 +76,13 @@ The ``Movie`` model class has the following definition: def __str__(self): return self.title +The ``Movie`` model class includes an inner ``Meta`` class and a ``__str__()`` method. +To learn about these model features, see :ref:`django-models-define` in the +Create Models guide. + +Run Code Examples +````````````````` + You can use the Python interactive shell to run the code examples. To enter the shell, run the following command from your project's root directory: @@ -103,7 +110,7 @@ Insert Documents ---------------- To insert a document into a collection, call the ``create()`` method on your -model's ``Manager`` class. Pass the new document's field names and field values +model's manager. Pass the new document's field names and field values as arguments to the ``create()`` method. Example @@ -128,14 +135,18 @@ code: movie = Movie(title="Poor Things", runtime=141) movie.save() +.. tip:: + + To learn more about the + .. _django-crud-read: Read Documents -------------- To retrieve documents from your collection, call the ``filter()`` method -on your model's ``Manager`` class. Pass a query filter, or criteria -that specifies which documents to retrieve, as an argument to the ``filter()`` method. +on your model's manager. Pass a query filter, or criteria that specifies +which documents to retrieve, as an argument to the ``filter()`` method. Alternatively, you can call the ``get()`` method to retrieve a single document that matches your query. @@ -204,9 +215,9 @@ Modify Documents ---------------- To modify documents in a collection, call the ``filter()`` and ``update()`` -methods on your model's ``Manager`` class. Pass a query filter, -or criteria that specifies which documents to update, as an argument to the -``filter()`` method. Then, pass the fields and values you want to update as +methods on your model's manager. Pass a query filter, or criteria that +specifies which documents to update, as an argument to the ``filter()`` +method. Then, pass the fields and values you want to update as arguments to the ``update()`` method. Example From 963638676bb5a5f70507eb140208f9bd7e855df3 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 21 Jan 2025 18:23:51 -0500 Subject: [PATCH 17/23] method links --- snooty.toml | 1 + source/interact-data/crud.txt | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/snooty.toml b/snooty.toml index ad8f4526..398268ab 100644 --- a/snooty.toml +++ b/snooty.toml @@ -18,6 +18,7 @@ intersphinx = [ "https://www.mongodb.com/docs/manual/objects.inv", "https://www.mongodb.com/docs/drivers/objects.inv", "https://www.mongodb.com/docs/atlas/objects.inv", + "http://docs.djangoproject.com/en/5.0/_objects/", ] sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/" diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 0f1e9924..9d1e5c0e 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -137,7 +137,9 @@ code: .. tip:: - To learn more about the + To learn more about the ``create()`` method, see + :meth:`~django.db.models.query.QuerySet.create()` in the {+framework+} + documentation. .. _django-crud-read: @@ -174,6 +176,12 @@ returns ``Movie`` objects that represent movies released on January 1, 2000: , , , ]> +.. tip:: + + To learn more about the ``filter()`` method, see + :meth:`~django.db.models.query.QuerySet.filter()` in the {+framework+} + documentation. + Return One Document Example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -206,8 +214,11 @@ retrieves a document in which the ``title`` value is ``"Boyhood"``: Movie.objects.filter(title="Boyhood").first() -.. TODO: To learn more about the ``first()`` method, see - :ref:`` in the Specify a Query guide. +.. tip:: + + To learn more about the ``get()`` method, see + :meth:`~django.db.models.query.QuerySet.get()` in the {+framework+} + documentation. .. _django-crud-modify: @@ -244,6 +255,12 @@ a document that has a ``title`` value of ``"High Fidelity"`` and adds a // Outputs the number of modified documents 1 +.. tip:: + + To learn more about the ``update()`` method, see + :meth:`~django.db.models.query.QuerySet.update()` in the {+framework+} + documentation. + .. _django-crud-delete: Delete Documents @@ -276,6 +293,12 @@ and deletes documents that have a ``runtime`` value of ``5``: // Outputs the number of deleted documents and objects (16, {'sample_mflix.Movie': 16}) +.. tip:: + + To learn more about the ``delete()`` method, see + :meth:`~django.db.models.query.QuerySet.delete()` in the {+framework+} + documentation. + Additional Information ---------------------- From 6b99b50db817dcf43dcc9274cfdb8b1cd05402d7 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 21 Jan 2025 18:29:19 -0500 Subject: [PATCH 18/23] test intersphinx --- snooty.toml | 1 + source/interact-data/crud.txt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/snooty.toml b/snooty.toml index 398268ab..41adbee1 100644 --- a/snooty.toml +++ b/snooty.toml @@ -18,6 +18,7 @@ intersphinx = [ "https://www.mongodb.com/docs/manual/objects.inv", "https://www.mongodb.com/docs/drivers/objects.inv", "https://www.mongodb.com/docs/atlas/objects.inv", + "https://docs.djangoproject.com/en/5.0/", "http://docs.djangoproject.com/en/5.0/_objects/", ] sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/" diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 9d1e5c0e..5b6e1730 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -80,6 +80,8 @@ The ``Movie`` model class includes an inner ``Meta`` class and a ``__str__()`` m To learn about these model features, see :ref:`django-models-define` in the Create Models guide. +Test: :class:`~django.db.models.IntegerField` + Run Code Examples ````````````````` From 64f1e0b5b4fa5f7f4907584e2b2f96d356b4a242 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 21 Jan 2025 18:31:32 -0500 Subject: [PATCH 19/23] fix --- snooty.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/snooty.toml b/snooty.toml index 41adbee1..398268ab 100644 --- a/snooty.toml +++ b/snooty.toml @@ -18,7 +18,6 @@ intersphinx = [ "https://www.mongodb.com/docs/manual/objects.inv", "https://www.mongodb.com/docs/drivers/objects.inv", "https://www.mongodb.com/docs/atlas/objects.inv", - "https://docs.djangoproject.com/en/5.0/", "http://docs.djangoproject.com/en/5.0/_objects/", ] sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/" From 89997766a88313fa667dd0c064b26a89ec1ac432 Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 21 Jan 2025 18:37:20 -0500 Subject: [PATCH 20/23] another test --- source/interact-data/crud.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 5b6e1730..9afae1b9 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -80,7 +80,7 @@ The ``Movie`` model class includes an inner ``Meta`` class and a ``__str__()`` m To learn about these model features, see :ref:`django-models-define` in the Create Models guide. -Test: :class:`~django.db.models.IntegerField` +Test: :djangoclass:`~django.db.models.IntegerField` Run Code Examples ````````````````` @@ -140,7 +140,7 @@ code: .. tip:: To learn more about the ``create()`` method, see - :meth:`~django.db.models.query.QuerySet.create()` in the {+framework+} + :django:meth:`~django.db.models.query.QuerySet.create()` in the {+framework+} documentation. .. _django-crud-read: From df740e81290152bd77de0db491411033dc2a3a8f Mon Sep 17 00:00:00 2001 From: norareidy Date: Tue, 21 Jan 2025 18:42:06 -0500 Subject: [PATCH 21/23] doesn't work, revert --- snooty.toml | 2 +- source/interact-data/crud.txt | 33 +++++++++++++++------------------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/snooty.toml b/snooty.toml index 398268ab..4eef4864 100644 --- a/snooty.toml +++ b/snooty.toml @@ -18,7 +18,6 @@ intersphinx = [ "https://www.mongodb.com/docs/manual/objects.inv", "https://www.mongodb.com/docs/drivers/objects.inv", "https://www.mongodb.com/docs/atlas/objects.inv", - "http://docs.djangoproject.com/en/5.0/_objects/", ] sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/" @@ -27,6 +26,7 @@ driver-short = "PyMongo" driver-long = "PyMongo, the MongoDB synchronous Python driver," driver-async = "PyMongo Async" django-odm = "Django MongoDB Backend" +django-docs = "https://docs.djangoproject.com/en/5.1/" framework = "Django" language = "Python" mdb-server = "MongoDB Server" diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 9afae1b9..cba161fd 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -80,8 +80,6 @@ The ``Movie`` model class includes an inner ``Meta`` class and a ``__str__()`` m To learn about these model features, see :ref:`django-models-define` in the Create Models guide. -Test: :djangoclass:`~django.db.models.IntegerField` - Run Code Examples ````````````````` @@ -139,9 +137,9 @@ code: .. tip:: - To learn more about the ``create()`` method, see - :django:meth:`~django.db.models.query.QuerySet.create()` in the {+framework+} - documentation. + To learn more about the ``create()`` method, see `create() + <{+django-docs+}/ref/models/querysets/#create>`__ in the {+framework+} + documentation. .. _django-crud-read: @@ -180,9 +178,9 @@ returns ``Movie`` objects that represent movies released on January 1, 2000: .. tip:: - To learn more about the ``filter()`` method, see - :meth:`~django.db.models.query.QuerySet.filter()` in the {+framework+} - documentation. + To learn more about the ``filter()`` method, see `filter() + <{+django-docs+}/ref/models/querysets/#filter>`__ in the {+framework+} + documentation. Return One Document Example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -218,9 +216,9 @@ retrieves a document in which the ``title`` value is ``"Boyhood"``: .. tip:: - To learn more about the ``get()`` method, see - :meth:`~django.db.models.query.QuerySet.get()` in the {+framework+} - documentation. + To learn more about the ``get()`` method, see `get() + <{+django-docs+}/ref/models/querysets/#get>`__ in the {+framework+} + documentation. .. _django-crud-modify: @@ -259,9 +257,9 @@ a document that has a ``title`` value of ``"High Fidelity"`` and adds a .. tip:: - To learn more about the ``update()`` method, see - :meth:`~django.db.models.query.QuerySet.update()` in the {+framework+} - documentation. + To learn more about the ``update()`` method, see `update() + <{+django-docs+}/ref/models/querysets/#update>`__ in the {+framework+} + documentation. .. _django-crud-delete: @@ -297,10 +295,9 @@ and deletes documents that have a ``runtime`` value of ``5``: .. tip:: - To learn more about the ``delete()`` method, see - :meth:`~django.db.models.query.QuerySet.delete()` in the {+framework+} - documentation. - + To learn more about the ``delete()`` method, see `delete() + <{+django-docs+}/ref/models/querysets/#delete>`__ in the {+framework+} + documentation. Additional Information ---------------------- From 73fe484cec7e93effa558e8743c194053ca522e1 Mon Sep 17 00:00:00 2001 From: norareidy Date: Wed, 22 Jan 2025 10:17:19 -0500 Subject: [PATCH 22/23] link fix --- source/interact-data/crud.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index cba161fd..e89248d9 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -138,8 +138,8 @@ code: .. tip:: To learn more about the ``create()`` method, see `create() - <{+django-docs+}/ref/models/querysets/#create>`__ in the {+framework+} - documentation. + <{+django-docs+}/ref/models/querysets/#create>`__ in the {+framework+} + documentation. .. _django-crud-read: @@ -179,8 +179,8 @@ 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. + <{+django-docs+}/ref/models/querysets/#filter>`__ in the {+framework+} + documentation. Return One Document Example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -217,8 +217,8 @@ 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. + <{+django-docs+}/ref/models/querysets/#get>`__ in the {+framework+} + documentation. .. _django-crud-modify: @@ -258,8 +258,8 @@ 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. + <{+django-docs+}/ref/models/querysets/#update>`__ in the {+framework+} + documentation. .. _django-crud-delete: @@ -296,8 +296,8 @@ 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. + <{+django-docs+}/ref/models/querysets/#delete>`__ in the {+framework+} + documentation. Additional Information ---------------------- From 60cc3818a7cd34920397d02fa52dcde8c7c24410 Mon Sep 17 00:00:00 2001 From: norareidy Date: Wed, 22 Jan 2025 13:03:29 -0500 Subject: [PATCH 23/23] remove embedded --- source/interact-data/crud.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index e89248d9..b424c3f2 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -59,14 +59,13 @@ The ``Movie`` model class has the following definition: .. code-block:: python from django.db import models - from django_mongodb_backend.fields import EmbeddedModelField, ArrayField + from django_mongodb_backend.fields import ArrayField class Movie(models.Model): title = models.CharField(max_length=200) plot = models.TextField(blank=True) runtime = models.IntegerField(default=0) released = models.DateTimeField("release date", null=True, blank=True) - awards = EmbeddedModelField(Award) genres = ArrayField(models.CharField(max_length=100), null=True, blank=True) class Meta: