Skip to content

Commit a697d62

Browse files
committed
remove IntegerField validators from MongoAutoField
1 parent 8f4c8e9 commit a697d62

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
@@ -71,8 +71,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
7171
"aggregation_regress.tests.AggregationTests.test_aggregation_with_generic_reverse_relation",
7272
# MongoAutoField.get_prep_value() must accept numeric pks.
7373
"model_forms.tests.ModelFormBasicTests.test_int_pks",
74-
# AutoField (IntegerField) validators crash MongoAutoField.
75-
"model_forms.tests.ModelFormBasicTests.test_recleaning_model_form_instance",
7674
}
7775
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
7876
_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)