Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Malcolm Tredinnick authored December 09, 2008
5  django/db/models/sql/query.py
@@ -1455,7 +1455,10 @@ def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
1455 1455
                     self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
1456 1456
 
1457 1457
         if pos != len(names) - 1:
1458  
-            raise FieldError("Join on field %r not permitted." % name)
  1458
+            if pos == len(names) - 2:
  1459
+                raise FieldError("Join on field %r not permitted. Did you misspell %r for the lookup type?" % (name, names[pos + 1]))
  1460
+            else:
  1461
+                raise FieldError("Join on field %r not permitted." % name)
1459 1462
 
1460 1463
         return field, target, opts, joins, last, extra_filters
1461 1464
 
2  tests/modeltests/lookup/models.py
@@ -293,7 +293,7 @@ def __unicode__(self):
293 293
 >>> Article.objects.filter(headline__starts='Article')
294 294
 Traceback (most recent call last):
295 295
     ...
296  
-FieldError: Join on field 'headline' not permitted.
  296
+FieldError: Join on field 'headline' not permitted. Did you misspell 'starts' for the lookup type?
297 297
 
298 298
 # Create some articles with a bit more interesting headlines for testing field lookups:
299 299
 >>> now = datetime.now()

0 notes on commit 5570b07

Please sign in to comment.
Something went wrong with that request. Please try again.