Skip to content
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

[Package Rename] django-mongodb -> django-mongodb-backend #208

Merged
merged 7 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 3 additions & 3 deletions .github/workflows/mongodb_settings.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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",
Expand Down Expand Up @@ -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:[email protected]/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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions django_mongodb/utils.py → django_mongodb_backend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -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__})."
)


Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
)
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/source/fields.rst
Original file line number Diff line number Diff line change
@@ -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``
-----------------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/forms.rst
Original file line number Diff line number Diff line change
@@ -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``
-----------------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/querysets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()``
-------------------
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion tests/backend_/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/backend_/utils/test_parse_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion tests/dbshell_/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/forms_tests_/test_objectidfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions tests/invalid_models_tests_/test_autofield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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",
)
Expand All @@ -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",
)
Expand All @@ -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",
)
Expand Down
2 changes: 1 addition & 1 deletion tests/model_fields_/models.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/model_fields_/test_autofield.py
Original file line number Diff line number Diff line change
@@ -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})

Expand Down
6 changes: 3 additions & 3 deletions tests/model_fields_/test_objectidfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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, {})

Expand Down
2 changes: 1 addition & 1 deletion tests/queries_/models.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/raw_query_/models.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Loading
Loading