Fixing dereferencing when the dereferenced-document wasn't found.
This commit is contained in:
parent
adb7bbeea0
commit
c081aca794
1 changed files with 4 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ import pymongo
|
||||||
import pymongo.objectid
|
import pymongo.objectid
|
||||||
import operator
|
import operator
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from bson.dbref import DBRef
|
||||||
|
|
||||||
|
|
||||||
class NotRegistered(Exception):
|
class NotRegistered(Exception):
|
||||||
|
|
@ -97,6 +98,9 @@ class BaseField(object):
|
||||||
|
|
||||||
# Get value from document instance if available, if not use default
|
# Get value from document instance if available, if not use default
|
||||||
value = instance._data.get(self.name)
|
value = instance._data.get(self.name)
|
||||||
|
if isinstance(value, DBRef):
|
||||||
|
raise ValueError("Can't dereference from the given DBRef (%s)" % str(value))
|
||||||
|
|
||||||
if value is None:
|
if value is None:
|
||||||
value = self.default
|
value = self.default
|
||||||
# Allow callable default values
|
# Allow callable default values
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue