Skip to content

Commit 14bed6b

Browse files
committed
removed IntegerField validators from MongoAutoField
1 parent 816b796 commit 14bed6b

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

.github/workflows/test-python.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ jobs:
4646
- name: Checkout Django
4747
uses: actions/checkout@v4
4848
with:
49-
repository: 'mongodb-forks/django'
50-
ref: 'mongodb-5.0.x'
49+
repository: 'timgraham/django'
50+
ref: 'mongoautofield-get-prep-value'
5151
path: 'django_repo'
5252
- name: Install system packages for Django's Python test dependencies
5353
run: |

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

@@ -38,3 +39,8 @@ def to_python(self, value):
3839
code="invalid",
3940
params={"value": value},
4041
) from None
42+
43+
@cached_property
44+
def validators(self):
45+
# Avoid IntegerField validators.
46+
return [*self.default_validators, *self._validators]

0 commit comments

Comments
 (0)