Improve error message for bad FK resolution
This commit is contained in:
parent
6e21a59402
commit
ade34c44da
|
@ -958,6 +958,8 @@ class ForeignObject(RelatedField):
|
||||||
def resolve_related_fields(self):
|
def resolve_related_fields(self):
|
||||||
if len(self.from_fields) < 1 or len(self.from_fields) != len(self.to_fields):
|
if len(self.from_fields) < 1 or len(self.from_fields) != len(self.to_fields):
|
||||||
raise ValueError('Foreign Object from and to fields must be the same non-zero length')
|
raise ValueError('Foreign Object from and to fields must be the same non-zero length')
|
||||||
|
if isinstance(self.rel.to, basestring):
|
||||||
|
raise ValueError('Related model %r cannot been resolved' % self.rel.to)
|
||||||
related_fields = []
|
related_fields = []
|
||||||
for index in range(len(self.from_fields)):
|
for index in range(len(self.from_fields)):
|
||||||
from_field_name = self.from_fields[index]
|
from_field_name = self.from_fields[index]
|
||||||
|
|
Loading…
Reference in New Issue