Skip to content

Commit 02022ab

Browse files
committed
removed IntegerField validators from MongoAutoField
1 parent df6ca51 commit 02022ab

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
@@ -61,8 +61,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
6161
"aggregation.tests.AggregateTestCase.test_aggregation_default_passed_another_aggregate",
6262
"aggregation.tests.AggregateTestCase.test_annotation_expressions",
6363
"aggregation.tests.AggregateTestCase.test_reverse_fkey_annotate",
64-
# AutoField (IntegerField) validators crash MongoAutoField.
65-
"model_forms.tests.ModelFormBasicTests.test_recleaning_model_form_instance",
6664
}
6765
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
6866
_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)