Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #9778 -- Added some special casing of the "Join on field 'abc'"…

… error

message. It now gives an extra hint if there's a chance you just made a typo in
the lookup type.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9620 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5570b0766d6b20732a5fd6112246ed8b27fdfc8c 1 parent 5e9c5de
@malcolmt malcolmt authored
View
5 django/db/models/sql/query.py
@@ -1455,7 +1455,10 @@ def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
if pos != len(names) - 1:
- raise FieldError("Join on field %r not permitted." % name)
+ if pos == len(names) - 2:
+ raise FieldError("Join on field %r not permitted. Did you misspell %r for the lookup type?" % (name, names[pos + 1]))
+ else:
+ raise FieldError("Join on field %r not permitted." % name)
return field, target, opts, joins, last, extra_filters
View
2  tests/modeltests/lookup/models.py
@@ -293,7 +293,7 @@ def __unicode__(self):
>>> Article.objects.filter(headline__starts='Article')
Traceback (most recent call last):
...
-FieldError: Join on field 'headline' not permitted.
+FieldError: Join on field 'headline' not permitted. Did you misspell 'starts' for the lookup type?
# Create some articles with a bit more interesting headlines for testing field lookups:
>>> now = datetime.now()
Please sign in to comment.
Something went wrong with that request. Please try again.