We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 936671c commit 6abb648Copy full SHA for 6abb648
django_mongodb/fields/auto.py
@@ -26,13 +26,16 @@ def get_prep_value(self, value):
26
try:
27
return ObjectId(value)
28
except errors.InvalidId as e:
29
+ # A manually assigned integer ID?
30
+ if isinstance(value, str) and value.isdigit():
31
+ return int(value)
32
raise ValueError(f"Field '{self.name}' expected an ObjectId but got {value!r}.") from e
33
34
def rel_db_type(self, connection):
35
return Field().db_type(connection=connection)
36
37
def to_python(self, value):
- if value is None:
38
+ if value is None or isinstance(value, int):
39
return value
40
41
0 commit comments