Skip to content

Commit 936671c

Browse files
timgrahamWaVEV
authored andcommitted
remove IntegerField validators from MongoAutoField
1 parent d58a457 commit 936671c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

django_mongodb/features.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
8383
"model_forms.test_modelchoicefield.ModelChoiceFieldTests.test_clean_model_instance",
8484
# MongoAutoField.get_prep_value() must accept numeric pks.
8585
"model_forms.tests.ModelFormBasicTests.test_int_pks",
86-
# AutoField (IntegerField) validators crash MongoAutoField.
87-
"model_forms.tests.ModelFormBasicTests.test_recleaning_model_form_instance",
8886
}
8987
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
9088
_django_test_expected_failures_bitwise = {

django_mongodb/fields/auto.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from bson import ObjectId, errors
22
from django.core import exceptions
33
from django.db.models.fields import AutoField, Field
4+
from django.utils.functional import cached_property
45
from django.utils.translation import gettext_lazy as _
56

67

@@ -41,3 +42,8 @@ def to_python(self, value):
4142
code="invalid",
4243
params={"value": value},
4344
) from None
45+
46+
@cached_property
47+
def validators(self):
48+
# Avoid IntegerField validators inherited from AutoField.
49+
return [*self.default_validators, *self._validators]

0 commit comments

Comments
 (0)