Skip to content

Commit 3234a85

Browse files
committed
revised docs
1 parent e1586f4 commit 3234a85

File tree

1 file changed

+70
-121
lines changed

1 file changed

+70
-121
lines changed

README.md

Lines changed: 70 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,25 @@ The development version of this package supports Django 5.0.x. To install it:
1010

1111
`pip install django-mongodb-backend`
1212

13-
## Get Started
13+
### Resources
1414

15-
This tutorial shows you how to create a Django app, connect to a MongoDB cluster hosted on MongoDB Atlas, and interact with data in your cluster.
15+
Check back soon as we aim to provide more links that will dive deeper into our library!
1616

17-
### Start a Project
18-
19-
From your shell, run the following command to create a new Django project called example based on a custom template:
17+
* [Developer Notes](DEV_NOTES.md)
2018

21-
```bash
22-
$ django-admin startproject example --template https://github.com/mongodb-labs/django-mongodb-project/archive/refs/heads/5.0.x.zip
23-
```
2419

25-
### Create a Connection String
20+
## Quickstart
2621

27-
Check out [Create a Connection String](https://deploy-preview-132--docs-pymongo.netlify.app/get-started/create-a-connection-string/) in our documentation to learn how to obtain a free MongoDB Atlas cluster.
22+
This tutorial shows you how to create a Django project, connect to a MongoDB cluster hosted on MongoDB Atlas, and interact with data in your cluster. To read more, please check our MongoDB Backend for Django tutorials page.
2823

29-
Once finished, your URI should look something like this:
30-
```bash
31-
mongodb+srv://<username>:<password>@samplecluster.jkiff1s.mongodb.net/?retryWrites=true&w=majority&appName=SampleCluster
32-
```
33-
Replace the `<username>` and `<password>` placeholders with your database user's username and password.
24+
### Start a Project
3425

35-
Then, specify a connection to your example database from the Atlas sample datasets by adding it after the hostname, as shown in the following example:
26+
From your shell, run the following command to create a new Django project called example based on a custom template:
3627

3728
```bash
38-
mongodb+srv://<username>:<password>@samplecluster.jkiff1s.mongodb.net/<DATABASE_NAME>?retryWrites=true&w=majority&appName=SampleCluster
29+
$ django-admin startproject example --template https://github.com/mongodb-labs/django-mongodb-project/archive/refs/heads/5.0.x.zip
3930
```
4031

41-
Replacing `<DATABASE_NAME>` with your database name of choice.
42-
4332

4433
### Connect to the Database
4534

@@ -60,129 +49,89 @@ python manage.py runserver
6049
```
6150
Then, visit http://127.0.0.1:8000/. This page displays a "Congratulations!" message and an image of a rocket.
6251

63-
Once you've done that, you'll see messages saying you haven't run migrations yet. Make sure to run this command:
64-
```bash
65-
python manage.py migrate
66-
```
67-
### Create an app
68-
An app is a web application that does something – e.g., a blog system, a database of public records or a small poll app.
6952

70-
From your project's root directory, run the following command to create a new Django app called polls based on a custom template:
53+
## Capabilities of Django Backend for MongoDB
7154

72-
```bash
73-
python manage.py startapp polls --template https://github.com/mongodb-labs/django-mongodb-app/archive/refs/heads/5.0.x.zip
74-
```
55+
- **Database Connectivity**
56+
57+
- Directly tune MongoDB connection settings within your Django configuration\!
58+
- Work against a persisted cloud instance of MongoDB for free\!
7559

76-
This will register a new `polls` app in your project, and provide the necessary files to have your polls app be a registered in `INSTALLED_APPS` within `example/settings.py` setting. It’ll look like this:
7760

78-
```python
79-
INSTALLED_APPS = [
80-
"polls.apps.PollsConfig",
81-
'example.apps.MongoAdminConfig',
82-
'example.apps.MongoAuthConfig',
83-
'example.apps.MongoContentTypesConfig',
84-
'django.contrib.sessions',
85-
'django.contrib.messages',
86-
'django.contrib.staticfiles',
87-
]
88-
```
61+
- **Model MongoDB Documents Through Django’s ORM**
62+
63+
- Translate Django model instances to MongoDB documents.
64+
- Create new collections corresponding to models.
65+
- Supports field validation, data storage, updating, and deletion.
66+
- Maps Django's built-in fields to MongoDB data types.
67+
- Provides new custom fields for arrays (ArrayField) and embedded documents (EmbeddedModelField).
68+
- Supports core migration functionalities including creating, deleting, and updating indexes and collections
8969

90-
### Make a Django Model
9170

92-
Go to `example/polls/models.py` and paste this example code to creat a `Poll` and `Question` model.
71+
- **Index Management**
72+
73+
- Create single, compound, and unique indexes using Django Indexes
74+
- Create MongoDB partial indexes in Django using Q notation.
9375

94-
```python
95-
from django.db import models
9676

77+
- **Querying Data**
78+
79+
- Querying API powered through the amazing MongoDB Aggregation Pipeline
80+
- Supports most functions of the Django QuerySet API
81+
- Support Query Annotations and common SQL AGGREGATE operators
82+
- We support foreign keys and execute JOIN operations all in 1 database call
83+
- Through our custom raw\_aggregate call, MQL operations like Vector Search, Atlas Search, and GeoSpatial querying still yield Django QuerySet results\!
9784

98-
class Question(models.Model):
99-
question_text = models.CharField(max_length=200)
100-
pub_date = models.DateTimeField("date published")
10185

86+
- **Administrator Dashboard & Authentication**
87+
88+
- Manage your data in Django’s admin site.
89+
- Fully integrated with Django's authentication framework.
90+
- Supports native user management features like creating users and sessions.
10291

103-
class Choice(models.Model):
104-
question = models.ForeignKey(Question, on_delete=models.CASCADE)
105-
choice_text = models.CharField(max_length=200)
106-
votes = models.IntegerField(default=0)
107-
```
10892

109-
With your new models defined and configs set, call the `makemigrations` command from the root of your directory.
110-
```bash
111-
python manage.py makemigrations polls
112-
```
93+
- **Management Commands**
94+
95+
- Use commands like `migrate`, `makemigrations`, `flush`, `sqlmigrate`, many more.
11396

114-
### Query your data
115-
Hop into the interactive Python shell provided by the Django api with this command:
116-
```bash
117-
python manage.py shell
118-
```
11997

120-
Within the shell, play around with creating, reading, updating, and deleting your models. Here's a few steps to start (provided by django tutorial):
121-
```python
122-
>>> from polls.models import Choice, Question # Import the model classes we just wrote.
123-
124-
# No questions are in the system yet.
125-
>>> Question.objects.all()
126-
<QuerySet []>
127-
128-
# Create a new Question.
129-
# Support for time zones is enabled in the default settings file, so
130-
# Django expects a datetime with tzinfo for pub_date. Use timezone.now()
131-
# instead of datetime.datetime.now() and it will do the right thing.
132-
>>> from django.utils import timezone
133-
>>> q = Question(question_text="What's new?", pub_date=timezone.now())
134-
135-
# Save the object into the database. You have to call save() explicitly.
136-
>>> q.save()
137-
138-
# Now it has an ID.
139-
>>> q.id
140-
1
141-
142-
# Access model field values via Python attributes.
143-
>>> q.question_text
144-
"What's new?"
145-
>>> q.pub_date
146-
datetime.datetime(2012, 2, 26, 13, 0, 0, 775217, tzinfo=datetime.timezone.utc)
147-
148-
# Change values by changing the attributes, then calling save().
149-
>>> q.question_text = "What's up?"
150-
>>> q.save()
151-
152-
# objects.all() displays all the questions in the database.
153-
>>> Question.objects.all()
154-
<QuerySet [<Question: Question object (1)>]>
155-
```
98+
## Future Commitments of Django Backend for MongoDB
99+
100+
- **Advanced Indexing**
101+
102+
- Support for advanced index types like geospatial, text, and vector search indexes.
103+
104+
- **Improved Data Modeling**
105+
106+
- Support ArrayFields containing Embedded Models
107+
- Support Collections with multiple Django Models
108+
- Possible support for additional Django fields such as ImageField
109+
110+
111+
- **Extended Querying Features**
112+
113+
- Exploring smoother ways to allow users to use full-text search, vector search, or geospatial querying.
114+
156115

157-
Check out the Django [database API](https://docs.djangoproject.com/en/5.1/topics/db/queries/) documentation for more information on queries.
116+
- **Enhanced Transactions Support**
117+
118+
- Investigation and support for transactions, allowing features like `ATOMIC_REQUESTS` and `AUTOCOMMIT`.
158119

159-
### View the Admin Dashboard
160-
1. Make the poll app modifiable in the admin site. Route to the `polls/admin.py` file and include this code:
161-
```python
162-
from django.contrib import admin
120+
- **Asynchronous Capabilities**
121+
122+
- Evaluation and support for Django’s asynchronous callback functions.
163123

164-
from .models import Question
165124

166-
admin.site.register(Question)
167-
```
168-
2. Create a superuser. When prompted, enter your desired username, password, and email address.
169-
```bash
170-
$ python manage.py createsuperuser
171-
```
172-
3. Start the Development Server
173-
```bash
174-
$ python manage.py runserver
175-
```
176-
4. Open a web browser and go to “/admin/” on your local domain – e.g., http://127.0.0.1:8000/admin/. Login and explore the free admin functionality!
125+
- **Performance Optimization**
126+
127+
- Focus on performance tuning, especially concerning JOIN operations and ensure competitive performance relative to SQL databases.
177128

178-
### Congrats! You've made your first Django MongoDB Backend Project
179129

180-
Check back soon as we aim to provide more links that will dive deeper into our library!
130+
- **Expanded Third-Party Library Support**
131+
132+
- Vet our backend library works effortlessly with major Django Third-Party solutions
181133

182-
<!-- * Developer Notes
183-
* Capabilities & Limitations
184-
* Tutorials
185-
* Troubleshooting -->
134+
These future capabilities are intended to enhance the functionality of the Django Backend for MongoDB as it progresses towards a General Availability (GA) release. If you have any more specific questions or need further details, feel free to ask\!
186135

187136
### Issues & Help
188137

0 commit comments

Comments
 (0)