diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index 63f8f6f0..dc543a1e 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -1,14 +1,14 @@ DATABASES = { "default": { - "ENGINE": "django_mongodb", + "ENGINE": "django_mongodb_backend", "NAME": "djangotests", }, "other": { - "ENGINE": "django_mongodb", + "ENGINE": "django_mongodb_backend", "NAME": "djangotests-other", }, } -DEFAULT_AUTO_FIELD = "django_mongodb.fields.ObjectIdAutoField" +DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField" PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",) SECRET_KEY = "django_tests_secret_key" USE_TZ = False diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index d9f7667c..f7b3e9a8 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -65,6 +65,23 @@ jobs: publish: needs: [build-dist, static-scan] + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: release + permissions: + id-token: write + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: all-dist-${{ github.run_id }} + path: dist/ + - name: Publish package distributions to PyPI + if: startsWith(inputs.dry_run, 'false') + uses: pypa/gh-action-pypi-publish@release/v1 + + post-publish: + needs: [publish] runs-on: ubuntu-latest environment: release permissions: diff --git a/.github/workflows/runtests.py b/.github/workflows/runtests.py index 831c2bf8..ebcc4876 100755 --- a/.github/workflows/runtests.py +++ b/.github/workflows/runtests.py @@ -149,7 +149,7 @@ "validation", "view_tests", "xor_lookups", - # Add directories in django_mongodb/tests + # Add directories in django_mongodb_backend/tests *sorted( [ x.name diff --git a/README.md b/README.md index 79731cd1..d1048c19 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ $ django-admin startproject mysite --template https://github.com/mongodb-labs/dj This template includes the following line in `settings.py`: ```python -DEFAULT_AUTO_FIELD = "django_mongodb.fields.ObjectIdAutoField" +DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField" ``` But this setting won't override any apps that have an `AppConfig` that @@ -42,15 +42,15 @@ from django.contrib.contenttypes.apps import ContentTypesConfig class MongoAdminConfig(AdminConfig): - default_auto_field = "django_mongodb.fields.ObjectIdAutoField" + default_auto_field = "django_mongodb_backend.fields.ObjectIdAutoField" class MongoAuthConfig(AuthConfig): - default_auto_field = "django_mongodb.fields.ObjectIdAutoField" + default_auto_field = "django_mongodb_backend.fields.ObjectIdAutoField" class MongoContentTypesConfig(ContentTypesConfig): - default_auto_field = "django_mongodb.fields.ObjectIdAutoField" + default_auto_field = "django_mongodb_backend.fields.ObjectIdAutoField" ``` Each app reference in the `INSTALLED_APPS` setting must point to the @@ -91,7 +91,7 @@ Whenever you run `python manage.py startapp`, you must remove the line: `default_auto_field = 'django.db.models.BigAutoField'` from the new application's `apps.py` file (or change it to reference - `"django_mongodb.fields.ObjectIdAutoField"`). + `"django_mongodb_backend.fields.ObjectIdAutoField"`). Alternatively, you can use the following `startapp` template which includes this change: @@ -109,7 +109,7 @@ to this: ```python DATABASES = { "default": { - "ENGINE": "django_mongodb", + "ENGINE": "django_mongodb_backend", "HOST": "mongodb+srv://cluster0.example.mongodb.net", "NAME": "my_database", "USER": "my_user", @@ -144,15 +144,15 @@ Alternatively, if you prefer to simply paste in a MongoDB URI rather than parse it into the format above, you can use: ```python -import django_mongodb +import django_mongodb_backend MONGODB_URI = "mongodb+srv://my_user:my_password@cluster0.example.mongodb.net/myDatabase?retryWrites=true&w=majority&tls=false" -DATABASES["default"] = django_mongodb.parse_uri(MONGODB_URI) +DATABASES["default"] = django_mongodb_backend.parse_uri(MONGODB_URI) ``` This constructs a `DATABASES` setting equivalent to the first example. -#### `django_mongodb.parse_uri(uri, conn_max_age=0, test=None)` +#### `django_mongodb_backend.parse_uri(uri, conn_max_age=0, test=None)` `parse_uri()` provides a few options to customize the resulting `DATABASES` setting, but for maximum flexibility, construct `DATABASES` manually as diff --git a/django_mongodb/__init__.py b/django_mongodb_backend/__init__.py similarity index 100% rename from django_mongodb/__init__.py rename to django_mongodb_backend/__init__.py diff --git a/django_mongodb/aggregates.py b/django_mongodb_backend/aggregates.py similarity index 100% rename from django_mongodb/aggregates.py rename to django_mongodb_backend/aggregates.py diff --git a/django_mongodb/base.py b/django_mongodb_backend/base.py similarity index 100% rename from django_mongodb/base.py rename to django_mongodb_backend/base.py diff --git a/django_mongodb/client.py b/django_mongodb_backend/client.py similarity index 100% rename from django_mongodb/client.py rename to django_mongodb_backend/client.py diff --git a/django_mongodb/compiler.py b/django_mongodb_backend/compiler.py similarity index 100% rename from django_mongodb/compiler.py rename to django_mongodb_backend/compiler.py diff --git a/django_mongodb/creation.py b/django_mongodb_backend/creation.py similarity index 100% rename from django_mongodb/creation.py rename to django_mongodb_backend/creation.py diff --git a/django_mongodb/dbapi.py b/django_mongodb_backend/dbapi.py similarity index 100% rename from django_mongodb/dbapi.py rename to django_mongodb_backend/dbapi.py diff --git a/django_mongodb/expressions.py b/django_mongodb_backend/expressions.py similarity index 100% rename from django_mongodb/expressions.py rename to django_mongodb_backend/expressions.py diff --git a/django_mongodb/features.py b/django_mongodb_backend/features.py similarity index 100% rename from django_mongodb/features.py rename to django_mongodb_backend/features.py diff --git a/django_mongodb/fields/__init__.py b/django_mongodb_backend/fields/__init__.py similarity index 100% rename from django_mongodb/fields/__init__.py rename to django_mongodb_backend/fields/__init__.py diff --git a/django_mongodb/fields/auto.py b/django_mongodb_backend/fields/auto.py similarity index 91% rename from django_mongodb/fields/auto.py rename to django_mongodb_backend/fields/auto.py index 8dd535ba..5bf84e67 100644 --- a/django_mongodb/fields/auto.py +++ b/django_mongodb_backend/fields/auto.py @@ -15,8 +15,10 @@ def deconstruct(self): name, path, args, kwargs = super().deconstruct() if self.db_column == "_id": del kwargs["db_column"] - if path.startswith("django_mongodb.fields.auto"): - path = path.replace("django_mongodb.fields.auto", "django_mongodb.fields") + if path.startswith("django_mongodb_backend.fields.auto"): + path = path.replace( + "django_mongodb_backend.fields.auto", "django_mongodb_backend.fields" + ) return name, path, args, kwargs def get_prep_value(self, value): diff --git a/django_mongodb/fields/duration.py b/django_mongodb_backend/fields/duration.py similarity index 100% rename from django_mongodb/fields/duration.py rename to django_mongodb_backend/fields/duration.py diff --git a/django_mongodb/fields/json.py b/django_mongodb_backend/fields/json.py similarity index 100% rename from django_mongodb/fields/json.py rename to django_mongodb_backend/fields/json.py diff --git a/django_mongodb/fields/objectid.py b/django_mongodb_backend/fields/objectid.py similarity index 83% rename from django_mongodb/fields/objectid.py rename to django_mongodb_backend/fields/objectid.py index b60ed6fb..ba430414 100644 --- a/django_mongodb/fields/objectid.py +++ b/django_mongodb_backend/fields/objectid.py @@ -3,7 +3,7 @@ from django.db.models.fields import Field from django.utils.translation import gettext_lazy as _ -from django_mongodb import forms +from django_mongodb_backend import forms class ObjectIdMixin: @@ -46,8 +46,11 @@ def formfield(self, **kwargs): class ObjectIdField(ObjectIdMixin, Field): def deconstruct(self): name, path, args, kwargs = super().deconstruct() - if path.startswith("django_mongodb.fields.objectid"): - path = path.replace("django_mongodb.fields.objectid", "django_mongodb.fields") + if path.startswith("django_mongodb_backend.fields.objectid"): + path = path.replace( + "django_mongodb_backend.fields.objectid", + "django_mongodb_backend.fields", + ) return name, path, args, kwargs def get_internal_type(self): diff --git a/django_mongodb/forms/__init__.py b/django_mongodb_backend/forms/__init__.py similarity index 100% rename from django_mongodb/forms/__init__.py rename to django_mongodb_backend/forms/__init__.py diff --git a/django_mongodb/forms/fields.py b/django_mongodb_backend/forms/fields.py similarity index 100% rename from django_mongodb/forms/fields.py rename to django_mongodb_backend/forms/fields.py diff --git a/django_mongodb/functions.py b/django_mongodb_backend/functions.py similarity index 100% rename from django_mongodb/functions.py rename to django_mongodb_backend/functions.py diff --git a/django_mongodb/indexes.py b/django_mongodb_backend/indexes.py similarity index 100% rename from django_mongodb/indexes.py rename to django_mongodb_backend/indexes.py diff --git a/django_mongodb/introspection.py b/django_mongodb_backend/introspection.py similarity index 100% rename from django_mongodb/introspection.py rename to django_mongodb_backend/introspection.py diff --git a/django_mongodb/lookups.py b/django_mongodb_backend/lookups.py similarity index 100% rename from django_mongodb/lookups.py rename to django_mongodb_backend/lookups.py diff --git a/django_mongodb/managers.py b/django_mongodb_backend/managers.py similarity index 100% rename from django_mongodb/managers.py rename to django_mongodb_backend/managers.py diff --git a/django_mongodb/operations.py b/django_mongodb_backend/operations.py similarity index 99% rename from django_mongodb/operations.py rename to django_mongodb_backend/operations.py index a6363bed..71b38350 100644 --- a/django_mongodb/operations.py +++ b/django_mongodb_backend/operations.py @@ -16,7 +16,7 @@ class DatabaseOperations(BaseDatabaseOperations): - compiler_module = "django_mongodb.compiler" + compiler_module = "django_mongodb_backend.compiler" combine_operators = { Combinable.ADD: "add", Combinable.SUB: "subtract", diff --git a/django_mongodb/query.py b/django_mongodb_backend/query.py similarity index 100% rename from django_mongodb/query.py rename to django_mongodb_backend/query.py diff --git a/django_mongodb/query_utils.py b/django_mongodb_backend/query_utils.py similarity index 100% rename from django_mongodb/query_utils.py rename to django_mongodb_backend/query_utils.py diff --git a/django_mongodb/queryset.py b/django_mongodb_backend/queryset.py similarity index 100% rename from django_mongodb/queryset.py rename to django_mongodb_backend/queryset.py diff --git a/django_mongodb/schema.py b/django_mongodb_backend/schema.py similarity index 100% rename from django_mongodb/schema.py rename to django_mongodb_backend/schema.py diff --git a/django_mongodb/utils.py b/django_mongodb_backend/utils.py similarity index 93% rename from django_mongodb/utils.py rename to django_mongodb_backend/utils.py index a8b4b95d..5b2051a8 100644 --- a/django_mongodb/utils.py +++ b/django_mongodb_backend/utils.py @@ -11,8 +11,8 @@ def check_django_compatability(): """ - Verify that this version of django-mongodb is compatible with the - installed version of Django. For example, any django-mongodb 5.0.x is + Verify that this version of django-mongodb-backend is compatible with the + installed version of Django. For example, any django-mongodb-backend 5.0.x is compatible with Django 5.0.y. """ from . import __version__ @@ -21,8 +21,8 @@ def check_django_compatability(): A = django.VERSION[0] B = django.VERSION[1] raise ImproperlyConfigured( - f"You must use the latest version of django-mongodb {A}.{B}.x " - f"with Django {A}.{B}.y (found django-mongodb {__version__})." + f"You must use the latest version of django-mongodb-backend {A}.{B}.x " + f"with Django {A}.{B}.y (found django-mongodb-backend {__version__})." ) @@ -44,7 +44,7 @@ def parse_uri(uri, conn_max_age=0, test=None): elif len(nodelist) > 1: host = ",".join([f"{host}:{port}" for host, port in nodelist]) settings_dict = { - "ENGINE": "django_mongodb", + "ENGINE": "django_mongodb_backend", "NAME": uri["database"], "HOST": host, "PORT": port, diff --git a/django_mongodb/validation.py b/django_mongodb_backend/validation.py similarity index 88% rename from django_mongodb/validation.py rename to django_mongodb_backend/validation.py index cb3d0d49..8ec418c7 100644 --- a/django_mongodb/validation.py +++ b/django_mongodb_backend/validation.py @@ -13,7 +13,7 @@ def check_field_type(self, field, field_type): checks.Error( f"{self.connection.display_name} does not support {field.__class__.__name__}.", obj=field, - hint="Use django_mongodb.fields.ObjectIdAutoField instead.", + hint="Use django_mongodb_backend.fields.ObjectIdAutoField instead.", id="mongodb.E001", ) ) diff --git a/docs/source/conf.py b/docs/source/conf.py index 564f763a..f81b9335 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -9,10 +9,10 @@ from importlib.metadata import version as _version -project = "django_mongodb" +project = "django_mongodb_backend" copyright = "2024, The MongoDB Python Team" author = "The MongoDB Python Team" -release = _version("django_mongodb") +release = _version("django_mongodb_backend") # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/docs/source/fields.rst b/docs/source/fields.rst index 0bb0feb3..58f30a62 100644 --- a/docs/source/fields.rst +++ b/docs/source/fields.rst @@ -1,9 +1,9 @@ Model field reference ===================== -.. module:: django_mongodb.fields +.. module:: django_mongodb_backend.fields -Some MongoDB-specific fields are available in ``django_mongodb.fields``. +Some MongoDB-specific fields are available in ``django_mongodb_backend.fields``. ``ObjectIdField`` ----------------- diff --git a/docs/source/forms.rst b/docs/source/forms.rst index 01b4f2f9..f3fa342b 100644 --- a/docs/source/forms.rst +++ b/docs/source/forms.rst @@ -1,9 +1,9 @@ Forms API reference =================== -.. module:: django_mongodb.forms +.. module:: django_mongodb_backend.forms -Some MongoDB-specific fields are available in ``django_mongodb.forms``. +Some MongoDB-specific fields are available in ``django_mongodb_backend.forms``. ``ObjectIdField`` ----------------- diff --git a/docs/source/querysets.rst b/docs/source/querysets.rst index fbdde933..4c024c77 100644 --- a/docs/source/querysets.rst +++ b/docs/source/querysets.rst @@ -6,7 +6,7 @@ Some MongoDB-specific ``QuerySet`` methods are available by adding a custom from django.db import models - from django_mongodb.managers import MongoManager + from django_mongodb_backend.managers import MongoManager class MyModel(models.Model): @@ -15,7 +15,7 @@ Some MongoDB-specific ``QuerySet`` methods are available by adding a custom objects = MongoManager() -.. currentmodule:: django_mongodb.queryset.MongoQuerySet +.. currentmodule:: django_mongodb_backend.queryset.MongoQuerySet ``raw_aggregate()`` ------------------- diff --git a/pyproject.toml b/pyproject.toml index 4fd41fef..a1081b32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["hatchling", "hatch-requirements-txt>=0.4.1"] build-backend = "hatchling.build" [project] -name = "django-mongodb" +name = "django-mongodb-backend" dynamic = ["version", "dependencies"] description = "MongoDB backend for Django" readme = "README.md" @@ -37,12 +37,12 @@ docs = [ "sphinx>=7"] [project.urls] Homepage = "https://www.mongodb.org" -Documentation = "https://django-mongodb.readthedocs.io" +Documentation = "https://django-mongodb-backend.readthedocs.io" Source = "https://github.com/mongodb-labs/django-mongodb" Tracker = "https://github.com/mongodb-labs/django-mongodb/issues" [tool.hatch.version] -path = "django_mongodb/__init__.py" +path = "django_mongodb_backend/__init__.py" validate-bump = false [tool.hatch.metadata.hooks.requirements_txt] diff --git a/tests/backend_/test_base.py b/tests/backend_/test_base.py index 9b084926..689c6dde 100644 --- a/tests/backend_/test_base.py +++ b/tests/backend_/test_base.py @@ -2,7 +2,7 @@ from django.db import connection from django.test import SimpleTestCase -from django_mongodb.base import DatabaseWrapper +from django_mongodb_backend.base import DatabaseWrapper class DatabaseWrapperTests(SimpleTestCase): diff --git a/tests/backend_/utils/test_parse_uri.py b/tests/backend_/utils/test_parse_uri.py index 01a479fb..c4d475f1 100644 --- a/tests/backend_/utils/test_parse_uri.py +++ b/tests/backend_/utils/test_parse_uri.py @@ -3,13 +3,13 @@ import pymongo from django.test import SimpleTestCase -from django_mongodb import parse_uri +from django_mongodb_backend import parse_uri class ParseURITests(SimpleTestCase): def test_simple_uri(self): settings_dict = parse_uri("mongodb://cluster0.example.mongodb.net/myDatabase") - self.assertEqual(settings_dict["ENGINE"], "django_mongodb") + self.assertEqual(settings_dict["ENGINE"], "django_mongodb_backend") self.assertEqual(settings_dict["NAME"], "myDatabase") self.assertEqual(settings_dict["HOST"], "cluster0.example.mongodb.net") diff --git a/tests/dbshell_/tests.py b/tests/dbshell_/tests.py index e85f25d2..7aeb71dd 100644 --- a/tests/dbshell_/tests.py +++ b/tests/dbshell_/tests.py @@ -4,7 +4,7 @@ from django.db import connection from django.test import SimpleTestCase -from django_mongodb.client import DatabaseClient +from django_mongodb_backend.client import DatabaseClient class MongoDbshellTests(SimpleTestCase): diff --git a/tests/forms_tests_/test_objectidfield.py b/tests/forms_tests_/test_objectidfield.py index fcbd1035..ee37401b 100644 --- a/tests/forms_tests_/test_objectidfield.py +++ b/tests/forms_tests_/test_objectidfield.py @@ -2,7 +2,7 @@ from django.core.exceptions import ValidationError from django.test import SimpleTestCase -from django_mongodb.forms.fields import ObjectIdField +from django_mongodb_backend.forms.fields import ObjectIdField class ObjectIdFieldTests(SimpleTestCase): diff --git a/tests/invalid_models_tests_/test_autofield.py b/tests/invalid_models_tests_/test_autofield.py index 4b3ea7e9..11225fe9 100644 --- a/tests/invalid_models_tests_/test_autofield.py +++ b/tests/invalid_models_tests_/test_autofield.py @@ -3,7 +3,7 @@ from django.test import SimpleTestCase from django.test.utils import isolate_apps -from django_mongodb.validation import DatabaseValidation +from django_mongodb_backend.validation import DatabaseValidation @isolate_apps("invalid_models_tests") @@ -19,7 +19,7 @@ class Model(models.Model): [ Error( "MongoDB does not support AutoField.", - hint="Use django_mongodb.fields.ObjectIdAutoField instead.", + hint="Use django_mongodb_backend.fields.ObjectIdAutoField instead.", obj=field, id="mongodb.E001", ) @@ -37,7 +37,7 @@ class Model(models.Model): [ Error( "MongoDB does not support BigAutoField.", - hint="Use django_mongodb.fields.ObjectIdAutoField instead.", + hint="Use django_mongodb_backend.fields.ObjectIdAutoField instead.", obj=field, id="mongodb.E001", ) @@ -55,7 +55,7 @@ class Model(models.Model): [ Error( "MongoDB does not support SmallAutoField.", - hint="Use django_mongodb.fields.ObjectIdAutoField instead.", + hint="Use django_mongodb_backend.fields.ObjectIdAutoField instead.", obj=field, id="mongodb.E001", ) diff --git a/tests/model_fields_/models.py b/tests/model_fields_/models.py index 10f21258..983827ed 100644 --- a/tests/model_fields_/models.py +++ b/tests/model_fields_/models.py @@ -1,6 +1,6 @@ from django.db import models -from django_mongodb.fields import ObjectIdField +from django_mongodb_backend.fields import ObjectIdField class ObjectIdModel(models.Model): diff --git a/tests/model_fields_/test_autofield.py b/tests/model_fields_/test_autofield.py index 6b068078..1ba2edc4 100644 --- a/tests/model_fields_/test_autofield.py +++ b/tests/model_fields_/test_autofield.py @@ -1,13 +1,13 @@ from django.test import SimpleTestCase -from django_mongodb.fields import ObjectIdAutoField +from django_mongodb_backend.fields import ObjectIdAutoField class MethodTests(SimpleTestCase): def test_deconstruct(self): field = ObjectIdAutoField() name, path, args, kwargs = field.deconstruct() - self.assertEqual(path, "django_mongodb.fields.ObjectIdAutoField") + self.assertEqual(path, "django_mongodb_backend.fields.ObjectIdAutoField") self.assertEqual(args, []) self.assertEqual(kwargs, {"primary_key": True}) diff --git a/tests/model_fields_/test_objectidfield.py b/tests/model_fields_/test_objectidfield.py index c37a5b79..13356522 100644 --- a/tests/model_fields_/test_objectidfield.py +++ b/tests/model_fields_/test_objectidfield.py @@ -5,8 +5,8 @@ from django.core.exceptions import ValidationError from django.test import SimpleTestCase, TestCase -from django_mongodb import forms -from django_mongodb.fields import ObjectIdField +from django_mongodb_backend import forms +from django_mongodb_backend.fields import ObjectIdField from .models import NullableObjectIdModel, ObjectIdModel, PrimaryKeyObjectIdModel @@ -15,7 +15,7 @@ class MethodTests(SimpleTestCase): def test_deconstruct(self): field = ObjectIdField() name, path, args, kwargs = field.deconstruct() - self.assertEqual(path, "django_mongodb.fields.ObjectIdField") + self.assertEqual(path, "django_mongodb_backend.fields.ObjectIdField") self.assertEqual(args, []) self.assertEqual(kwargs, {}) diff --git a/tests/queries_/models.py b/tests/queries_/models.py index acf2bef2..01510224 100644 --- a/tests/queries_/models.py +++ b/tests/queries_/models.py @@ -1,6 +1,6 @@ from django.db import models -from django_mongodb.fields import ObjectIdAutoField, ObjectIdField +from django_mongodb_backend.fields import ObjectIdAutoField, ObjectIdField class Author(models.Model): diff --git a/tests/raw_query_/models.py b/tests/raw_query_/models.py index aab01de6..4b647c9c 100644 --- a/tests/raw_query_/models.py +++ b/tests/raw_query_/models.py @@ -1,7 +1,7 @@ from django.db import models -from django_mongodb.fields import ObjectIdAutoField -from django_mongodb.managers import MongoManager +from django_mongodb_backend.fields import ObjectIdAutoField +from django_mongodb_backend.managers import MongoManager class Author(models.Model): diff --git a/tests/raw_query_/test_raw_aggregate.py b/tests/raw_query_/test_raw_aggregate.py index dd2fd48b..91e844e6 100644 --- a/tests/raw_query_/test_raw_aggregate.py +++ b/tests/raw_query_/test_raw_aggregate.py @@ -7,7 +7,7 @@ from django.core.exceptions import FieldDoesNotExist from django.test import TestCase -from django_mongodb.queryset import RawQuerySet +from django_mongodb_backend.queryset import RawQuerySet from .models import ( Author,