From ade34c44dae4f5cf9d51bf7f900bf06efa98ff12 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Thu, 9 May 2013 14:04:07 +0100 Subject: [PATCH] Improve error message for bad FK resolution --- django/db/models/fields/related.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index c92bdb6468..728d78ba52 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -958,6 +958,8 @@ class ForeignObject(RelatedField): 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]