File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -69,8 +69,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
69
69
"aggregation_regress.tests.AggregationTests.test_more_more_more3" ,
70
70
# Incorrect JOIN with GenericRelation gives incorrect results.
71
71
"aggregation_regress.tests.AggregationTests.test_aggregation_with_generic_reverse_relation" ,
72
- # MongoAutoField.get_prep_value() must accept numeric pks.
73
- "model_forms.tests.ModelFormBasicTests.test_int_pks" ,
74
72
}
75
73
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
76
74
_django_test_expected_failures_bitwise = {
Original file line number Diff line number Diff line change @@ -26,13 +26,16 @@ def get_prep_value(self, value):
26
26
try :
27
27
return ObjectId (value )
28
28
except errors .InvalidId as e :
29
+ # A manually assigned integer ID?
30
+ if isinstance (value , str ) and value .isdigit ():
31
+ return int (value )
29
32
raise ValueError (f"Field '{ self .name } ' expected an ObjectId but got { value !r} ." ) from e
30
33
31
34
def rel_db_type (self , connection ):
32
35
return Field ().db_type (connection = connection )
33
36
34
37
def to_python (self , value ):
35
- if value is None :
38
+ if value is None or isinstance ( value , int ) :
36
39
return value
37
40
try :
38
41
return ObjectId (value )
You can’t perform that action at this time.
0 commit comments