Skip to content

Commit f84bb84

Browse files
committed
allow MongoAutoField to use int
1 parent 14bed6b commit f84bb84

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

django_mongodb/fields/auto.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ def __init__(self, *args, **kwargs):
1818
def get_prep_value(self, value):
1919
if value is None:
2020
return None
21-
if isinstance(value, ObjectId):
21+
# Accept int for compatibility with Django's test suite which has many
22+
# instances of manually assigned integer IDs, as well as for things
23+
# like settings.SITE_ID which has a system check requiring an integer.
24+
if isinstance(value, (ObjectId | int)):
2225
return value
2326
try:
2427
return ObjectId(value)

0 commit comments

Comments
 (0)