[Django] #23697: Confusing exception raised upon unknown field in queryset filter argument

23 views
Skip to first unread message

Django

unread,
Oct 21, 2014, 2:58:58 AM10/21/14
to django-...@googlegroups.com
#23697: Confusing exception raised upon unknown field in queryset filter argument
-------------------------------+--------------------
Reporter: mbertheau | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
`Choice.objects.filter(question__qestion_text__icontains='foo')`
`#################### typo here: ^^`

raises

{{{
File "/home/markus/src/django/django/db/models/sql/query.py", line 1181,
in build_filter
lookups, value)
File "/home/markus/src/django/django/db/models/fields/related.py", line
1514, in get_lookup_constraint
raise exceptions.FieldError('Relation fields do not support nested
lookups')
FieldError: Relation fields do not support nested lookups
}}}

Which is very confusing. Is a better error message possible?

(This might have been the original cause of #23351.)

--
Ticket URL: <https://code.djangoproject.com/ticket/23697>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 21, 2014, 3:06:12 AM10/21/14
to django-...@googlegroups.com
#23697: Confusing exception raised upon unknown field in queryset filter argument
-------------------------------+------------------------------------

Reporter: mbertheau | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by akaariai):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

Better error messages are always welcome. I believe we could throw away
the current error message and instead tell the user which fields are
available. This would match pre-1.7 error message.

--
Ticket URL: <https://code.djangoproject.com/ticket/23697#comment:1>

Django

unread,
Oct 31, 2014, 8:47:07 AM10/31/14
to django-...@googlegroups.com
#23697: Confusing exception raised upon unknown field in queryset filter argument
-------------------------------------+-------------------------------------
Reporter: mbertheau | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.7
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* type: Uncategorized => Cleanup/optimization
* component: Uncategorized => Database layer (models, ORM)


--
Ticket URL: <https://code.djangoproject.com/ticket/23697#comment:2>

Django

unread,
Feb 12, 2015, 1:08:21 AM2/12/15
to django-...@googlegroups.com
#23697: Confusing exception raised upon unknown field in queryset filter argument
-------------------------------------+-------------------------------------
Reporter: mbertheau | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 1.7
(models, ORM) |

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by charettes):

#23351 was a duplicate which manifested itself in the admins
`search_fields` references.

--
Ticket URL: <https://code.djangoproject.com/ticket/23697#comment:3>

Django

unread,
Mar 22, 2015, 7:05:00 AM3/22/15
to django-...@googlegroups.com
#23697: Confusing exception raised upon unknown field in queryset filter argument
-------------------------------------+-------------------------------------
Reporter: mbertheau | Owner: exonian
Type: | Status: assigned

Cleanup/optimization |
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by exonian):

* status: new => assigned
* owner: nobody => exonian


--
Ticket URL: <https://code.djangoproject.com/ticket/23697#comment:4>

Django

unread,
Mar 22, 2015, 10:08:43 AM3/22/15
to django-...@googlegroups.com
#23697: Confusing exception raised upon unknown field in queryset filter argument
-------------------------------------+-------------------------------------
Reporter: mbertheau | Owner: exonian
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by exonian):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/4375

--
Ticket URL: <https://code.djangoproject.com/ticket/23697#comment:5>

Django

unread,
Mar 22, 2015, 10:30:30 AM3/22/15
to django-...@googlegroups.com
#23697: Confusing exception raised upon unknown field in queryset filter argument
-------------------------------------+-------------------------------------
Reporter: mbertheau | Owner: exonian
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by phalt):

* stage: Accepted => Ready for checkin


Comment:

Looks good.

--
Ticket URL: <https://code.djangoproject.com/ticket/23697#comment:6>

Django

unread,
Mar 23, 2015, 10:32:21 AM3/23/15
to django-...@googlegroups.com
#23697: Confusing exception raised upon unknown field in queryset filter argument
-------------------------------------+-------------------------------------
Reporter: mbertheau | Owner: exonian
Type: | Status: closed

Cleanup/optimization |
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"00e667728ba3ef1b5cb3de0e11c7648b89315a91" 00e66772]:
{{{
#!CommitTicketReference repository=""
revision="00e667728ba3ef1b5cb3de0e11c7648b89315a91"
Fixed #23697 -- Improved ForeignObject.get_lookup_constraint() error
message.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23697#comment:7>

Reply all
Reply to author
Forward
0 new messages