Skip to content

Commit c863134

Browse files
committed
TG feedback
1 parent 595ee65 commit c863134

File tree

6 files changed

+30
-46
lines changed

6 files changed

+30
-46
lines changed

source/django-get-started/django-connect-mongodb.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ you can create a Django project that connects to MongoDB.
6464
.. code-block:: bash
6565

6666
DATABASES = {
67-
"default": {
68-
"ENGINE": "django_mongodb_backend",
69-
"NAME": "sample_mflix",
70-
"USER": "<username>",
71-
"PASSWORD": "<password>",
72-
"HOST": "<connection string URI>",
73-
},
67+
"default": {
68+
"ENGINE": "django_mongodb_backend",
69+
"NAME": "sample_mflix",
70+
"USER": "<username>",
71+
"PASSWORD": "<password>",
72+
"HOST": "<connection string URI>",
73+
},
7474
}
7575

7676
Replace the ``<username>`` and ``<password>`` placeholders with your

source/django-get-started/django-create-admin.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Create an Admin Site
1313

1414
You can create a Django admin site to edit your application's
1515
data from a web interface. To learn more about the Django admin
16-
site and its features, see `The Django admin site <https://docs.djangoproject.com/en/5.1/ref/contrib/admin/>`__
16+
site and its features, see `The Django admin site <https://docs.djangoproject.com/en/{+django-version-number+}/ref/contrib/admin/>`__
1717
in the Django documentation.
1818

1919
.. procedure::

source/django-get-started/django-create-app.txt

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To learn more about the ``sample_mflix`` database, see :atlas:`Sample Mflix Data
3131

3232
.. code-block:: bash
3333

34-
python3 manage.py startapp sample_mflix --template https://github.com/mongodb-labs/django-mongodb-app/archive/refs/heads/5.0.x.zip
34+
python3 manage.py startapp sample_mflix --template https://github.com/mongodb-labs/django-mongodb-app/archive/refs/heads/{+django-version-number+}.x.zip
3535

3636
.. note:: App Template
3737

@@ -50,11 +50,12 @@ To learn more about the ``sample_mflix`` database, see :atlas:`Sample Mflix Data
5050

5151
class Movie(models.Model):
5252
title = models.CharField(max_length=200)
53-
plot = models.TextField(null=True)
53+
plot = models.TextField(blank=True)
5454
runtime = models.IntegerField(default=0)
55-
released = models.DateTimeField("release date", null=True)
55+
released = models.DateTimeField("release date", null=True, blank=True)
5656
awards = EmbeddedModelField(Award)
57-
genres = ArrayField(models.CharField(max_length=100), blank=True)
57+
genres = ArrayField(models.CharField(max_length=100), null=True, blank=True)
58+
objects = MongoManager()
5859

5960
class Meta:
6061
db_table = "movies"
@@ -67,9 +68,6 @@ To learn more about the ``sample_mflix`` database, see :atlas:`Sample Mflix Data
6768
nominations = models.IntegerField(default=0)
6869
text = models.CharField(max_length=100)
6970

70-
class Meta:
71-
abstract = True
72-
7371
class Viewer(models.Model):
7472
name = models.CharField(max_length=100)
7573
email = models.CharField(max_length=200)
@@ -108,14 +106,13 @@ To learn more about the ``sample_mflix`` database, see :atlas:`Sample Mflix Data
108106
def index(request):
109107
return HttpResponse("Hello, world. You're at the application index.")
110108

111-
112109
def recent_movies(request):
113-
movies = Movie.objects.all().order_by('-released')[:5]
114-
return render(request, 'recent_movies.html', {'movies': movies})
110+
movies = Movie.objects.order_by("-released")[:5]
111+
return render(request, "recent_movies.html", {"movies": movies})
115112

116113
def viewers_list(request):
117-
viewers = Viewer.objects.all().order_by('name')[:10]
118-
return render(request, 'viewers_list.html', {'viewers': viewers})
114+
viewers = Viewer.objects.order_by("name")[:10]
115+
return render(request, "viewers_list.html", {"viewers": viewers})
119116

120117
These views display a landing page message and information about your ``Movie``
121118
and ``Viewer`` models.
@@ -134,8 +131,8 @@ To learn more about the ``sample_mflix`` database, see :atlas:`Sample Mflix Data
134131

135132
urlpatterns = [
136133
path("", views.index, name="index"),
137-
path('recent_movies/', views.recent_movies, name='recent_movies'),
138-
path('viewers_list/', views.viewers_list, name='viewers_list'),
134+
path("recent_movies/", views.recent_movies, name="recent_movies"),
135+
path("viewers_list/", views.viewers_list, name="viewers_list"),
139136
]
140137

141138
Then, navigate to the ``quickstart/urls.py`` file and replace its contents with

source/django-get-started/django-install.txt

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ in your development environment.
1919

2020
.. step:: Install the dependencies
2121

22-
Before installing {+django-odm+}, ensure you have the following dependencies installed
23-
in your development environment:
24-
25-
- `Python3 version 3.10 or later <https://www.python.org/downloads/>`__
26-
- `pip <https://pip.pypa.io/en/stable/installation/>`__
22+
Before installing {+django-odm+}, ensure you have `Python 3.10 or later <https://www.python.org/downloads/>`__
23+
installed in your development environment.
2724

2825
.. step:: Create a virtual environment
2926

@@ -68,16 +65,6 @@ in your development environment.
6865
- PyMongo version {+version-number+} and its dependencies
6966
- Django version {+django-version-number+} and its dependencies
7067

71-
.. important::
72-
73-
If you have already installed PyMongo and Django in your
74-
development environment, ensure that they fulfill the following
75-
version requirements:
76-
77-
- PyMongo: Your version must be greater than or equal to 4.6 and less than 5.0.
78-
- Django: Your version must be greater than or equal to 5.0 and less than 5.1.
79-
80-
8168
After you complete these steps, you have {+django-odm+} and its
8269
dependencies installed in your development environment.
8370

source/django-get-started/django-query-data.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ to read data from the ``sample_mflix`` database.
1919

2020
.. step:: Query the "users" collection for a specified email
2121

22-
Start a Python shell and import the required models
23-
by running the following code:
22+
Start a Python shell by running the following command:
2423

2524
.. code-block:: bash
2625

2726
python3 manage.py shell
28-
from sample_mflix.models import Movie, Viewer
2927

3028
Then, run the following code to query the
3129
``sample_mflix.users`` collection for a movie viewer whose email is
3230
3331

34-
.. code-block:: bash
32+
.. code-block:: python
3533

34+
from sample_mflix.models import Movie, Viewer
35+
3636
Viewer.objects.filter(email="[email protected]").first()
3737

3838
This code returns the name of the matching user:
@@ -48,7 +48,7 @@ to read data from the ``sample_mflix`` database.
4848
collection for movies that have a ``runtime`` value less than
4949
``10``:
5050

51-
.. code-block:: bash
51+
.. code-block:: python
5252

5353
Movie.objects.filter(runtime__lt=10)
5454

source/django-get-started/django-write-data.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ and delete functions on your model objects.
3131
.. step:: Import the required classes and modules
3232

3333
From your Python shell, run the following code to import
34-
your models and the modules for creating a ``datetime`` object:
34+
your models and the module for creating a ``datetime`` object:
3535

3636
.. code-block:: python
3737

@@ -47,11 +47,11 @@ and delete functions on your model objects.
4747

4848
.. code-block:: python
4949

50-
movie_awards = Awards(wins=122, nominations=245, text="Won 1 Oscar")
50+
movie_awards = Award(wins=122, nominations=245, text="Won 1 Oscar")
5151
movie = Movie(title="Minari", plot=
5252
"A Korean-American family moves to an Arkansas farm in search of their own American Dream",
53-
runtime=217, released=timezone.make_aware(datetime(2020, 1, 26, 0, 0),
54-
timezone.get_current_timezone()), awards=movie_awards, genres=["Drama", "Comedy"])
53+
runtime=217, released=timezone.make_aware(datetime(2020, 1, 26, 0, 0)),
54+
awards=movie_awards, genres=["Drama", "Comedy"])
5555

5656
Save the object to store its data as a document in the ``movies``
5757
collection, as shown in the following code:

0 commit comments

Comments
 (0)