Skip to content

Commit c9b0922

Browse files
committed
rename MongoAutoField to ObjectIdAutoField
1 parent 0e50614 commit c9b0922

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

.github/workflows/mongodb_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"NAME": "djangotests-other",
99
},
1010
}
11-
DEFAULT_AUTO_FIELD = "django_mongodb.fields.MongoAutoField"
11+
DEFAULT_AUTO_FIELD = "django_mongodb.fields.ObjectIdAutoField"
1212
PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",)
1313
SECRET_KEY = "django_tests_secret_key"
1414
USE_TZ = False

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ DATABASES = {
4949
[`MongoClient`](https://pymongo.readthedocs.io/en/stable/api/pymongo/mongo_client.html).
5050

5151
In your Django settings, you must specify that all models should use
52-
`MongoAutoField`.
52+
`ObjectIdAutoField`.
5353

5454
```python
55-
DEFAULT_AUTO_FIELD = "django_mongodb.fields.MongoAutoField"
55+
DEFAULT_AUTO_FIELD = "django_mongodb.fields.ObjectIdAutoField"
5656
```
5757

5858
This won't override any apps that have an `AppConfig` that specifies
@@ -68,22 +68,22 @@ from django.contrib.contenttypes.apps import ContentTypesConfig
6868

6969

7070
class MongoAdminConfig(AdminConfig):
71-
default_auto_field = "django_mongodb.fields.MongoAutoField"
71+
default_auto_field = "django_mongodb.fields.ObjectIdAutoField"
7272

7373

7474
class MongoAuthConfig(AuthConfig):
75-
default_auto_field = "django_mongodb.fields.MongoAutoField"
75+
default_auto_field = "django_mongodb.fields.ObjectIdAutoField"
7676

7777

7878
class MongoContentTypesConfig(ContentTypesConfig):
79-
default_auto_field = "django_mongodb.fields.MongoAutoField"
79+
default_auto_field = "django_mongodb.fields.ObjectIdAutoField"
8080
```
8181

8282
Then replace each app reference in the `INSTALLED_APPS` setting with the new
8383
``AppConfig``. For example, replace `'django.contrib.admin'` with
8484
`'mysite.apps.MongoAdminConfig'`.
8585

86-
Because all models must use `MongoAutoField`, each third-party and contrib app
86+
Because all models must use `ObjectIdAutoField`, each third-party and contrib app
8787
you use needs to have its own migrations specific to MongoDB.
8888

8989
For example, you might configure your settings like this:

django_mongodb/fields/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from .auto import MongoAutoField
1+
from .auto import ObjectIdAutoField
22
from .duration import register_duration_field
33
from .json import register_json_field
44

5-
__all__ = ["register_fields", "MongoAutoField"]
5+
__all__ = ["register_fields", "ObjectIdAutoField"]
66

77

88
def register_fields():

django_mongodb/fields/auto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.utils.translation import gettext_lazy as _
66

77

8-
class MongoAutoField(AutoField):
8+
class ObjectIdAutoField(AutoField):
99
default_error_messages = {
1010
"invalid": _("“%(value)s” value must be an Object Id."),
1111
}

0 commit comments

Comments
 (0)