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 51afeca commit 5998fc7Copy full SHA for 5998fc7
mongoengine/base/fields.py
@@ -511,7 +511,8 @@ def to_python(self, value):
511
def to_mongo(self, value):
512
if not isinstance(value, ObjectId):
513
try:
514
- return ObjectId(str(value))
+ if value:
515
+ return ObjectId(str(value))
516
except Exception as e:
517
self.error(str(e))
518
return value
0 commit comments