Skip to content

Add MongoRouter to DATABASE_ROUTERS #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In order to use it with your version of Django:

```bash
django-admin --version
>> 5.0
>> 5.1
```

## Create the Django project
Expand All @@ -20,9 +20,9 @@ replacing the `{{ project_name }}` and `{{ version }}` sections.
django-admin startproject {{ project_name }} --template https://github.com/mongodb-labs/django-mongodb-project/archive/refs/heads/{{ version }}.x.zip
```

For a project named `5_0_example` that runs on `django==5.0.*`
For a project named `5_1_example` that runs on `django==5.1.*`
the command would look like this:

```bash
django-admin startproject 5_0_example --template https://github.com/mongodb-labs/django-mongodb-project/archive/refs/heads/5.0.x.zip
```
django-admin startproject 5_1_example --template https://github.com/mongodb-labs/django-mongodb-project/archive/refs/heads/5.1.x.zip
```
4 changes: 4 additions & 0 deletions project_name/settings.py-tpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ DATABASES = {
"default": django_mongodb_backend.parse_uri("mongodb://localhost:27017/{{ project_name }}"),
}

# Custom database router
# https://docs.djangoproject.com/en/dev/ref/settings/#database-routers
DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"]

# Password validation
# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#auth-password-validators

Expand Down