From 7bb7342512adbc0a9df7c3a819809ad00493b4b1 Mon Sep 17 00:00:00 2001 From: Jib Date: Mon, 6 Jan 2025 15:22:00 -0500 Subject: [PATCH 1/6] renamed django-mongodb -> django-mongodb-backend --- .github/workflows/mongodb_settings.py | 6 +++--- .github/workflows/runtests.py | 2 +- README.md | 18 +++++++++--------- .../__init__.py | 0 .../aggregates.py | 0 .../base.py | 0 .../client.py | 0 .../compiler.py | 0 .../creation.py | 0 .../dbapi.py | 0 .../expressions.py | 0 .../features.py | 0 .../fields/__init__.py | 0 .../fields/auto.py | 4 ++-- .../fields/duration.py | 0 .../fields/json.py | 0 .../fields/objectid.py | 6 +++--- .../forms/__init__.py | 0 .../forms/fields.py | 0 .../functions.py | 0 .../indexes.py | 0 .../introspection.py | 0 .../lookups.py | 0 .../managers.py | 0 .../operations.py | 2 +- .../query.py | 0 .../query_utils.py | 0 .../queryset.py | 0 .../schema.py | 0 .../utils.py | 10 +++++----- .../validation.py | 2 +- docs/source/conf.py | 4 ++-- docs/source/fields.rst | 4 ++-- docs/source/forms.rst | 4 ++-- docs/source/querysets.rst | 4 ++-- pyproject.toml | 6 +++--- tests/backend_/test_base.py | 2 +- tests/backend_/utils/test_parse_uri.py | 4 ++-- tests/dbshell_/tests.py | 2 +- tests/forms_tests_/test_objectidfield.py | 2 +- tests/invalid_models_tests_/test_autofield.py | 8 ++++---- tests/model_fields_/models.py | 2 +- tests/model_fields_/test_autofield.py | 4 ++-- tests/model_fields_/test_objectidfield.py | 6 +++--- tests/queries_/models.py | 2 +- tests/raw_query_/models.py | 4 ++-- tests/raw_query_/test_raw_aggregate.py | 2 +- 47 files changed, 55 insertions(+), 55 deletions(-) rename {django_mongodb => django_mongodb_backend}/__init__.py (100%) rename {django_mongodb => django_mongodb_backend}/aggregates.py (100%) rename {django_mongodb => django_mongodb_backend}/base.py (100%) rename {django_mongodb => django_mongodb_backend}/client.py (100%) rename {django_mongodb => django_mongodb_backend}/compiler.py (100%) rename {django_mongodb => django_mongodb_backend}/creation.py (100%) rename {django_mongodb => django_mongodb_backend}/dbapi.py (100%) rename {django_mongodb => django_mongodb_backend}/expressions.py (100%) rename {django_mongodb => django_mongodb_backend}/features.py (100%) rename {django_mongodb => django_mongodb_backend}/fields/__init__.py (100%) rename {django_mongodb => django_mongodb_backend}/fields/auto.py (92%) rename {django_mongodb => django_mongodb_backend}/fields/duration.py (100%) rename {django_mongodb => django_mongodb_backend}/fields/json.py (100%) rename {django_mongodb => django_mongodb_backend}/fields/objectid.py (86%) rename {django_mongodb => django_mongodb_backend}/forms/__init__.py (100%) rename {django_mongodb => django_mongodb_backend}/forms/fields.py (100%) rename {django_mongodb => django_mongodb_backend}/functions.py (100%) rename {django_mongodb => django_mongodb_backend}/indexes.py (100%) rename {django_mongodb => django_mongodb_backend}/introspection.py (100%) rename {django_mongodb => django_mongodb_backend}/lookups.py (100%) rename {django_mongodb => django_mongodb_backend}/managers.py (100%) rename {django_mongodb => django_mongodb_backend}/operations.py (99%) rename {django_mongodb => django_mongodb_backend}/query.py (100%) rename {django_mongodb => django_mongodb_backend}/query_utils.py (100%) rename {django_mongodb => django_mongodb_backend}/queryset.py (100%) rename {django_mongodb => django_mongodb_backend}/schema.py (100%) rename {django_mongodb => django_mongodb_backend}/utils.py (93%) rename {django_mongodb => django_mongodb_backend}/validation.py (88%) diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index 63f8f6f0c..dc543a1e9 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/runtests.py b/.github/workflows/runtests.py index 831c2bf89..ebcc4876f 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 79731cd10..d1048c193 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 92% rename from django_mongodb/fields/auto.py rename to django_mongodb_backend/fields/auto.py index 8dd535ba0..92df9ed60 100644 --- a/django_mongodb/fields/auto.py +++ b/django_mongodb_backend/fields/auto.py @@ -15,8 +15,8 @@ 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 86% rename from django_mongodb/fields/objectid.py rename to django_mongodb_backend/fields/objectid.py index b60ed6fb9..1c40608de 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,8 @@ 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 a6363bede..71b38350b 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 a8b4b95d9..5b2051a8a 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 cb3d0d495..8ec418c79 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 564f763a6..f81b9335f 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 0bb0feb3a..58f30a626 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 01b4f2f9e..f3fa342b8 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 fbdde9338..4c024c773 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 4fd41fef0..a1081b326 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 9b0849264..689c6dde7 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 01a479fb7..c4d475f1f 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 e85f25d21..7aeb71ddd 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 fcbd10352..ee37401b2 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 4b3ea7e96..11225fe96 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 10f212587..983827ed6 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 6b0680786..1ba2edc41 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 c37a5b79a..13356522a 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 acf2bef25..015102248 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 aab01de6c..4b647c9c7 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 dd2fd48b4..91e844e68 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, From b2096db2c19bf3fd46d0b49fd24b2e64a0758538 Mon Sep 17 00:00:00 2001 From: Jib Date: Mon, 6 Jan 2025 15:56:53 -0500 Subject: [PATCH 2/6] linting --- django_mongodb_backend/fields/auto.py | 8 ++++++-- django_mongodb_backend/fields/objectid.py | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/django_mongodb_backend/fields/auto.py b/django_mongodb_backend/fields/auto.py index 92df9ed60..6c785c709 100644 --- a/django_mongodb_backend/fields/auto.py +++ b/django_mongodb_backend/fields/auto.py @@ -16,7 +16,9 @@ def deconstruct(self): if self.db_column == "_id": del kwargs["db_column"] if path.startswith("django_mongodb_backend.fields.auto"): - path = path.replace("django_mongodb_backend.fields.auto", "django_mongodb_backend.fields") + path = path.replace( + "django_mongodb_backend.fields.auto", "django_mongodb_backend.fields" + ) return name, path, args, kwargs def get_prep_value(self, value): @@ -33,7 +35,9 @@ def get_prep_value(self, value): # A manually assigned integer ID? if isinstance(value, str) and value.isdigit(): return int(value) - raise ValueError(f"Field '{self.name}' expected an ObjectId but got {value!r}.") from e + raise ValueError( + f"Field '{self.name}' expected an ObjectId but got {value!r}." + ) from e def get_internal_type(self): return "ObjectIdAutoField" diff --git a/django_mongodb_backend/fields/objectid.py b/django_mongodb_backend/fields/objectid.py index 1c40608de..ba4304144 100644 --- a/django_mongodb_backend/fields/objectid.py +++ b/django_mongodb_backend/fields/objectid.py @@ -47,7 +47,10 @@ class ObjectIdField(ObjectIdMixin, Field): def deconstruct(self): name, path, args, kwargs = super().deconstruct() if path.startswith("django_mongodb_backend.fields.objectid"): - path = path.replace("django_mongodb_backend.fields.objectid", "django_mongodb_backend.fields") + path = path.replace( + "django_mongodb_backend.fields.objectid", + "django_mongodb_backend.fields", + ) return name, path, args, kwargs def get_internal_type(self): From 541b214cd1fb1ad20c57e7b37309f6c2eb2c1351 Mon Sep 17 00:00:00 2001 From: Jib Date: Mon, 6 Jan 2025 16:00:06 -0500 Subject: [PATCH 3/6] ruff format --- django_mongodb_backend/fields/auto.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/django_mongodb_backend/fields/auto.py b/django_mongodb_backend/fields/auto.py index 6c785c709..5bf84e67d 100644 --- a/django_mongodb_backend/fields/auto.py +++ b/django_mongodb_backend/fields/auto.py @@ -35,9 +35,7 @@ def get_prep_value(self, value): # A manually assigned integer ID? if isinstance(value, str) and value.isdigit(): return int(value) - raise ValueError( - f"Field '{self.name}' expected an ObjectId but got {value!r}." - ) from e + raise ValueError(f"Field '{self.name}' expected an ObjectId but got {value!r}.") from e def get_internal_type(self): return "ObjectIdAutoField" From 77aa2f5054731ff9277253c036597f3bca430893 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 6 Jan 2025 16:28:33 -0600 Subject: [PATCH 4/6] update publish step --- .github/workflows/release-python.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index d9f7667c9..56438f74e 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: @@ -91,5 +108,4 @@ jobs: silk_asset_group: ${{ env.SILK_ASSET_GROUP }} evergreen_project: ${{ env.EVERGREEN_PROJECT }} token: ${{ github.token }} - repository_url: https://test.pypi.org/legacy/ dry_run: ${{ inputs.dry_run }} From 1208bfffea0b71d58bb890f0cb5ec6799d2794a3 Mon Sep 17 00:00:00 2001 From: Jib Date: Tue, 7 Jan 2025 15:49:43 -0500 Subject: [PATCH 5/6] testing first using test.pypi on automated workflow --- .github/workflows/release-python.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 56438f74e..1b1e01d0e 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -108,4 +108,5 @@ jobs: silk_asset_group: ${{ env.SILK_ASSET_GROUP }} evergreen_project: ${{ env.EVERGREEN_PROJECT }} token: ${{ github.token }} - dry_run: ${{ inputs.dry_run }} + repository_url: https://test.pypi.org/legacy/ + dry_run: ${{ inputs.dry_run }} \ No newline at end of file From f8b7e399c610b70a9cf714dd2fbc4fd77fb2de2f Mon Sep 17 00:00:00 2001 From: Jib Date: Tue, 7 Jan 2025 16:17:55 -0500 Subject: [PATCH 6/6] fix EOF --- .github/workflows/release-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 1b1e01d0e..f7b3e9a8f 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -109,4 +109,4 @@ jobs: evergreen_project: ${{ env.EVERGREEN_PROJECT }} token: ${{ github.token }} repository_url: https://test.pypi.org/legacy/ - dry_run: ${{ inputs.dry_run }} \ No newline at end of file + dry_run: ${{ inputs.dry_run }}