From 8ac8dcfd867131e410af390e3475b8b99d2bd2bb Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Clark" Date: Mon, 24 Feb 2025 15:56:03 -0500 Subject: [PATCH 1/6] Add MongoRouter to DATABASE_ROUTERS - https://github.com/mongodb/django-mongodb-backend/pull/259 --- project_name/settings.py-tpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project_name/settings.py-tpl b/project_name/settings.py-tpl index 3a90b69..df605e6 100644 --- a/project_name/settings.py-tpl +++ b/project_name/settings.py-tpl @@ -125,3 +125,5 @@ MIGRATION_MODULES = { 'auth': 'mongo_migrations.auth', 'contenttypes': 'mongo_migrations.contenttypes', } + +DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"] From 77d3863a5010b1c931ad50f795f277db19976136 Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Clark" Date: Mon, 24 Feb 2025 17:08:49 -0500 Subject: [PATCH 2/6] Move router setting under db setting --- project_name/settings.py-tpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/project_name/settings.py-tpl b/project_name/settings.py-tpl index df605e6..c478739 100644 --- a/project_name/settings.py-tpl +++ b/project_name/settings.py-tpl @@ -78,6 +78,7 @@ WSGI_APPLICATION = '{{ project_name }}.wsgi.application' DATABASES = { "default": django_mongodb_backend.parse_uri("mongodb://localhost:27017/{{ project_name }}"), } +DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"] # Password validation # https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#auth-password-validators @@ -125,5 +126,3 @@ MIGRATION_MODULES = { 'auth': 'mongo_migrations.auth', 'contenttypes': 'mongo_migrations.contenttypes', } - -DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"] From a4a4ec555178634933e34fbfef1025b1fcc3b7a5 Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Clark" Date: Tue, 25 Feb 2025 07:13:27 -0500 Subject: [PATCH 3/6] Blank line --- project_name/settings.py-tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/project_name/settings.py-tpl b/project_name/settings.py-tpl index c478739..1663931 100644 --- a/project_name/settings.py-tpl +++ b/project_name/settings.py-tpl @@ -78,6 +78,7 @@ WSGI_APPLICATION = '{{ project_name }}.wsgi.application' DATABASES = { "default": django_mongodb_backend.parse_uri("mongodb://localhost:27017/{{ project_name }}"), } + DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"] # Password validation From 5f2ec9f0ba2bba6071734ff63366f2dec0cb2bf0 Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Clark" Date: Tue, 25 Feb 2025 12:06:53 -0500 Subject: [PATCH 4/6] Add comment --- project_name/settings.py-tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/project_name/settings.py-tpl b/project_name/settings.py-tpl index 1663931..73fbce7 100644 --- a/project_name/settings.py-tpl +++ b/project_name/settings.py-tpl @@ -79,6 +79,7 @@ DATABASES = { "default": django_mongodb_backend.parse_uri("mongodb://localhost:27017/{{ project_name }}"), } +# Add a database router so dumpdata can ignore embedded models DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"] # Password validation From a7aa94ed9873b66ce98926765f86c26219ac79fa Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Clark" Date: Wed, 26 Feb 2025 16:36:49 -0500 Subject: [PATCH 5/6] Update comment --- project_name/settings.py-tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project_name/settings.py-tpl b/project_name/settings.py-tpl index 73fbce7..3d80dee 100644 --- a/project_name/settings.py-tpl +++ b/project_name/settings.py-tpl @@ -79,7 +79,8 @@ DATABASES = { "default": django_mongodb_backend.parse_uri("mongodb://localhost:27017/{{ project_name }}"), } -# Add a database router so dumpdata can ignore embedded models +# Custom database router +# https://docs.djangoproject.com/en/dev/ref/settings/#database-routers DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"] # Password validation From 26b863c037dd5812689bd70ff2712087def7c2cd Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Clark" Date: Tue, 18 Mar 2025 11:27:38 -0400 Subject: [PATCH 6/6] Update for 5.1 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f4fb0e9..094c6d7 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 -``` \ No newline at end of file +django-admin startproject 5_1_example --template https://github.com/mongodb-labs/django-mongodb-project/archive/refs/heads/5.1.x.zip +```