Permalink
Browse files

Improve error message for bad FK resolution

  • Loading branch information...
1 parent 6e21a59 commit ade34c44dae4f5cf9d51bf7f900bf06efa98ff12 @andrewgodwin andrewgodwin committed May 9, 2013
Showing with 2 additions and 0 deletions.
  1. +2 −0 django/db/models/fields/related.py
View
2 django/db/models/fields/related.py
@@ -958,6 +958,8 @@ def __init__(self, to, from_fields, to_fields, **kwargs):
def resolve_related_fields(self):
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')
+ if isinstance(self.rel.to, basestring):
+ raise ValueError('Related model %r cannot been resolved' % self.rel.to)
related_fields = []
for index in range(len(self.from_fields)):
from_field_name = self.from_fields[index]

0 comments on commit ade34c4

Please sign in to comment.