Skip to content

Commit 38a08c8

Browse files
committed
Merge remote-tracking branch 'upstream/master' into DOCSP-46322-raw-queries
2 parents 39ba0a5 + f8c7bd5 commit 38a08c8

File tree

11 files changed

+393
-6
lines changed

11 files changed

+393
-6
lines changed

.github/pull_request_template.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Pull Request Info
2+
3+
[PR Reviewing Guidelines](https://github.com/mongodb/docs-django/blob/master/REVIEWING.md)
4+
5+
JIRA - <https://jira.mongodb.org/browse/DOCSP-NNNNN>
6+
7+
### Staging Links
8+
9+
<!-- start insert-links --><!-- end insert-links -->
10+
11+
## Self-Review Checklist
12+
13+
- [ ] Is this free of any warnings or errors in the RST?
14+
- [ ] Did you run a spell-check?
15+
- [ ] Did you run a grammar-check?
16+
- [ ] Are all the links working?
17+
- [ ] Are the [facets and meta keywords](https://wiki.corp.mongodb.com/display/DE/Docs+Taxonomy) accurate?
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Add Netlify Links To Changed Pages
2+
on:
3+
workflow_call:
4+
pull_request_target:
5+
jobs:
6+
get-pr-changes:
7+
name: Get Changed Files & Update PR Description
8+
runs-on: ubuntu-latest
9+
permissions:
10+
issues: write
11+
contents: write
12+
pull-requests: write
13+
repository-projects: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Get Changed Files
17+
id: changed-files
18+
# pin to a specific commit to ensure stability
19+
uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c
20+
with:
21+
separator: ","
22+
files: source/**
23+
- name: Build Netlify Links for Changed Pages
24+
id: build_page_links
25+
env:
26+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
27+
run: |
28+
new_links=""
29+
base_link='https://deploy-preview-${{ github.event.number }}--docs-django.netlify.app'
30+
files=$(echo "$CHANGED_FILES" | tr "," "\n")
31+
for file in $files; do
32+
echo "processing ${file}"
33+
if (! grep -s "includes/" <<< "$file") &&
34+
(! grep -s "images/" <<< "$file") &&
35+
(! grep -s "examples/" <<< "$file"); then
36+
file="${file#source}"
37+
file="${file%.txt}"
38+
filenoslash="${file:1}"
39+
echo "${base_link}${file}"
40+
new_links+="<li><a href=${base_link}${file}>${filenoslash}</a></li>"
41+
else
42+
echo "(file skipped)"
43+
fi
44+
done
45+
if [ "$new_links" == "" ]; then
46+
new_links="No pages to preview"
47+
fi
48+
echo "Final new_links string: "
49+
echo "${new_links}"
50+
echo "staging_links=${new_links}" >> "$GITHUB_OUTPUT"
51+
- name: Update the PR Description
52+
uses: MongoCaleb/pr-description-action@master
53+
with:
54+
regex: "<!-- start insert-links -->.*<!-- end insert-links -->"
55+
appendContentOnMatchOnly: true
56+
regexFlags: is
57+
content: "<!-- start insert-links -->\n${{ steps.build_page_links.outputs.staging_links }}\n<!-- end insert-links -->"
58+
token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Django MongoDB Backend Documentation
22

3-
[Your words here].
3+
This repository contains documentation for Django MongoDB Backend, the
4+
Django database backend that uses PyMongo to connect to MongoDB.
45

56
## Report Issues
67

REVIEWING.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Pull Request Reviewing Guidelines for the Django MongoDB Backend Documentation
2+
3+
Contributions to the set of documents in this repository can receive reviews from one or both of the following types of reviews:
4+
5+
1. A **copy review**, which focuses on information structure and wording; typically performed by a MongoDB Documentation Team member
6+
2. A **technical review**, which addresses code snippets and the technical correctness of prose; typically performed by a MongoDB engineer.
7+
8+
See the following sections for reviewer expectations for each type of pull request (PR) review:
9+
10+
## Copy Review
11+
12+
Review the structure, wording, and flow of the information in the PR, and correct it if necessary.
13+
14+
### What to Review
15+
16+
- Wording
17+
- Page structure
18+
- Technical content to the extent of the reviewer's understanding.
19+
- Whether the PR fulfills the Acceptance Criteria described in the
20+
linked JIRA ticket.
21+
22+
### What Not to Review
23+
24+
Nothing is completely off-limits to a copy review of a PR -- if you notice a technical issue, it's best to call it out early.
25+
Copy reviewers should constrain their reviews to content within the scope of the JIRA ticket, or otherwise create PRs to address anything unrelated.
26+
27+
## Technical Review
28+
29+
Review the technical accuracy and completeness of a PR and correct it if necessary.
30+
31+
### What to Review
32+
33+
- Code snippets; ensure the code is idiomatic and that all technical claims are correct. e.g. ("To create a `Foo`, use the `Bar.createFoo()` method")
34+
- Problematic explanations that could trip up users who try to follow the documentation.
35+
36+
### What Not to Review
37+
38+
While we welcome any recommendations on wording and structure, avoid blocking approval based on any copy edits. Please entrust the author to make the writing decisions based on style guidelines and team-specific writing conventions, and to create PRs to address anything they deem outside the technical review scope.
39+
40+
- Wording of sentences, although corrections to technical claims are welcome
41+
- Structure of the page
42+
- Any unchanged lines outside the PR unless relevant to the ticket
43+
acceptance criteria.

snooty.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ toc_landing_pages = [
1111

1212
[constants]
1313
django-odm = "Django MongoDB Backend"
14-
django-api = "https://django-mongodb.readthedocs.io/en/latest/"
14+
api = "https://django-mongodb.readthedocs.io/en/latest/"
1515
mdb-server = "MongoDB Server"
16+
django-version = "5.0"
17+
django-docs = "https://docs.djangoproject.com/en/{+django-version+}"

source/compatibility.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.. _django-compatibility:
2+
3+
=============
4+
Compatibility
5+
=============
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
.. facet::
14+
:name: genre
15+
:values: reference
16+
17+
.. meta::
18+
:keywords: backwards compatibility, versions, upgrade
19+
20+
MongoDB Compatibility
21+
---------------------
22+
23+
{+django-odm+} uses the PyMongo driver to interact with MongoDB. The {+mdb-server+}
24+
versions that your application supports depend on your PyMongo version.
25+
To view PyMongo and {+mdb-server+} compatibility information, see `MongoDB Compatibility
26+
<https://www.mongodb.com/docs/languages/python/pymongo-driver/current/compatibility/#mongodb-compatibility>`__
27+
in the PyMongo documentation.
28+
29+
PyMongo Compatibility
30+
---------------------
31+
32+
{+django-odm+} supports PyMongo versions 4.6 and later.
33+
34+
Django Compatibility
35+
--------------------
36+
37+
Your major and minor version of {+django-odm+} must match your Django version.
38+
For example, {+django-odm+} version 5.1 requires Django 5.1. The minimum supported
39+
Django version is 5.0.
40+
41+
Language Compatibility
42+
----------------------
43+
44+
The following compatibility table specifies the recommended version of
45+
{+django-odm+} for use with a specific version of Python:
46+
47+
.. include:: /includes/language-compatibility-table-django.rst
48+
49+
For more information on how to read the compatibility tables, see our guide on
50+
:driver:`MongoDB Compatibility Tables. </about-compatibility>`
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# start-models
2+
from django.db import models
3+
from django_mongodb_backend.fields import EmbeddedModelField, ArrayField
4+
5+
class Award(models.Model):
6+
wins = models.IntegerField(default=0)
7+
nominations = models.IntegerField(default=0)
8+
text = models.CharField(max_length=100)
9+
10+
class Meta:
11+
managed = False
12+
13+
class Movie(models.Model):
14+
title = models.CharField(max_length=200)
15+
plot = models.TextField(blank=True)
16+
runtime = models.IntegerField(default=0)
17+
released = models.DateTimeField("release date", null=True, blank=True)
18+
awards = EmbeddedModelField(Award)
19+
genres = ArrayField(models.CharField(max_length=100), null=True, blank=True)
20+
imdb = models.JSONField(null=True)
21+
22+
class Meta:
23+
db_table = "movies"
24+
managed = False
25+
26+
def __str__(self):
27+
return self.title
28+
# end-models
29+
30+
# start-all
31+
Movie.objects.all()
32+
# end-all
33+
34+
# start-filter
35+
Movie.objects.filter(runtime=300)
36+
# end-filter
37+
38+
# start-get
39+
Movie.objects.get(title="Finding Nemo")
40+
# end-get
41+
42+
# start-exclude
43+
Movie.objects.exclude(released__lt=timezone.make_aware(datetime(1980, 1, 1)))
44+
# end-exclude
45+
46+
# start-filter-contains
47+
Movie.objects.filter(plot__contains="coming-of-age")
48+
# end-filter-contains
49+
50+
# start-filter-lte
51+
Movie.objects.filter(runtime__lte=50)
52+
# end-filter-lte
53+
54+
# start-filter-relationships
55+
Movie.objects.filter(awards__wins=93)
56+
# end-filter-relationships
57+
58+
# start-filter-combine
59+
Movie.objects.filter(awards__text__istartswith="nominated")
60+
# end-filter-combine
61+
62+
# start-sort
63+
Movie.objects.filter(title__startswith="Rocky").order_by("released")
64+
# end-sort
65+
66+
# start-limit
67+
Movie.objects.filter(released=timezone.make_aware(datetime(2010, 7, 16)))[2:4]
68+
# end-limit
69+
70+
# start-first
71+
Movie.objects.filter(genres=["Crime", "Comedy"]).first()
72+
# end-first
73+
74+
# start-json
75+
Movie.objects.filter(imdb__votes__gt=900000)
76+
# end-json
77+
78+
# start-kt
79+
from django.db.models.fields.json import KT
80+
81+
Movie.objects.annotate(score=KT("imdb__rating")).all().order_by("-score")
82+
# end-kt
83+
84+
# start-primary-key-pk
85+
from bson import ObjectId
86+
87+
Movie.objects.get(pk=ObjectId("573a1394f29313caabce0d37"))
88+
# end-primary-key-pk
89+
90+
# start-primary-key-id
91+
from bson import ObjectId
92+
93+
Movie.objects.get(id=ObjectId("573a1394f29313caabce0d37"))
94+
# end-primary-key-id
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.. list-table::
2+
:header-rows: 1
3+
:stub-columns: 1
4+
:class: compatibility-large
5+
6+
* - {+django-odm+} Version
7+
- Python 3.13
8+
- Python 3.12
9+
- Python 3.11
10+
- Python 3.10
11+
- Python 3.9
12+
13+
* - 5.1
14+
-
15+
- ✓
16+
- ✓
17+
- ✓
18+
-
19+
20+
* - 5.0
21+
-
22+
- ✓
23+
- ✓
24+
- ✓
25+
-

source/index.txt

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,65 @@ Django MongoDB Backend
1111

1212
.. toctree::
1313

14-
Interact with Data </interact-data>
14+
Interact with Data </interact-data>
15+
Issues & Help </issues-and-help>
16+
Compatibility </compatibility>
17+
18+
19+
.. TODO:
20+
Get Started </get-started>
21+
Connection Configuration </connect>
22+
Model Your Data </model-data>
23+
Django Feature Limitations </feature-limitations>
24+
API Documentation <{+api+}>
25+
26+
Introduction
27+
------------
1528

1629
Welcome to the documentation site for the official {+django-odm+},
1730
a Django database backend that uses PyMongo to connect to MongoDB.
1831

1932
Interact with Data
2033
------------------
2134

22-
Learn how to use {+ddjango-odm+} to perform operations on MongoDB data
23-
in the :ref:`django-interact-data` section.
35+
Learn how to use {+django-odm+} to perform operations on MongoDB data
36+
in the :ref:`django-interact-data` section.
37+
38+
.. TODO:
39+
40+
.. Get Started
41+
.. -----------
42+
43+
.. Learn how to install {+django-odm+}, establish a connection to MongoDB, and begin
44+
working with data in the :ref:`django-get-started` tutorial.
45+
46+
.. Connect to MongoDB
47+
.. ------------------
48+
49+
.. Learn how to configure a connection to a MongoDB deployment
50+
in the :ref:`django-connection-configuration` section.
51+
52+
.. Model Your Data
53+
.. ---------------
54+
55+
.. Learn how to create Django models that represent MongoDB collections
56+
in the :ref:`django-model-data` section.
57+
58+
.. Django Feature Limitations
59+
.. --------------------------
60+
61+
.. Learn about the Django features that {+django-odm+} does not support
62+
in the :ref:`django-feature-limitations` section.
63+
64+
Compatibility
65+
-------------
66+
67+
Learn about the versions of {+mdb-server+}, PyMongo, Python, and Django
68+
that are compatible with {+django-odm+} in the :ref:`Compatibility <django-compatibility>`
69+
section.
70+
71+
Issues & Help
72+
-------------
73+
74+
Learn how to report bugs, contribute to {+django-odm+}, and find more resources for
75+
receiving help in the :ref:`Issues & Help <django-issues-and-help>` section.

source/interact-data/raw-queries.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Additional Information
288288
----------------------
289289

290290
To view more examples that use the ``raw_aggregate()`` method,
291-
see `QuerySet API Reference <{+django-api+}querysets.html>`__
291+
see `QuerySet API Reference <{+api+}querysets.html>`__
292292
in the {+django-odm+} API documentation.
293293

294294
To learn more about running aggregation operations, see

0 commit comments

Comments
 (0)