Author: mtredinnick
Date: 2008-12-09 01:03:52 -0600 (Tue, 09 Dec 2008)
New Revision: 9620
Modified:
django/trunk/django/db/models/sql/query.py
django/trunk/tests/modeltests/lookup/models.py
Log:
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.
Modified: django/trunk/django/db/models/sql/query.py
===================================================================
--- django/trunk/django/db/models/sql/query.py 2008-12-09 06:51:23 UTC (rev
9619)
+++ django/trunk/django/db/models/sql/query.py 2008-12-09 07:03:52 UTC (rev
9620)
@@ -1455,7 +1455,10 @@
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
Modified: django/trunk/tests/modeltests/lookup/models.py
===================================================================
--- django/trunk/tests/modeltests/lookup/models.py 2008-12-09 06:51:23 UTC
(rev 9619)
+++ django/trunk/tests/modeltests/lookup/models.py 2008-12-09 07:03:52 UTC
(rev 9620)
@@ -293,7 +293,7 @@
>>> 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()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---