[Django] #29804: Add 'Did You Mean' For Common Unsupported Lookups

9 views
Skip to first unread message

Django

unread,
Sep 28, 2018, 2:39:30 PM9/28/18
to django-...@googlegroups.com
#29804: Add 'Did You Mean' For Common Unsupported Lookups
-----------------------------------------+------------------------
Reporter: Rich Jones | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
I often find myself running into `django.core.exceptions.FieldError:
Unsupported lookup 'is_null' for DateTimeField or join on the field not
permitted.` - and it seems like plenty of other people on StackOverflow do
as well.

It'd be great if we hit an unsupported lookup, we could suggest the
correct one if if it's similar, so it'd become:

`django.core.exceptions.FieldError: Unsupported lookup 'is_null' for
DateTimeField or join on the field not permitted - did you mean isnull?`

Thanks!

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

Django

unread,
Sep 28, 2018, 3:00:37 PM9/28/18
to django-...@googlegroups.com
#29804: Add 'Did you mean' suggestions for unsupported lookup error
-------------------------------------+-------------------------------------

Reporter: Rich Jones | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 2.1
(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 Tim Graham):

* component: Uncategorized => Database layer (models, ORM)
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted


Comment:

It seems worth exploring. `difflib` from the standard library seems
promising for the example you gave:
{{{
>>> import difflib
>>> difflib.get_close_matches('is_null', ['isnull'])
['isnull']
}}}

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

Django

unread,
Sep 29, 2018, 12:25:45 AM9/29/18
to django-...@googlegroups.com
#29804: Add 'Did you mean' suggestions for unsupported lookup error
-------------------------------------+-------------------------------------
Reporter: Rich Jones | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 2.1
(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 Ubadub):

Is the purpose of this ticket to add "did you mean" suggestions for
"django.core.exceptions.FieldError" only, or for any similar error?

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

Django

unread,
Sep 29, 2018, 12:34:14 AM9/29/18
to django-...@googlegroups.com
#29804: Add 'Did you mean' suggestions for unsupported lookup error
-------------------------------------+-------------------------------------
Reporter: Rich Jones | Owner: Ubadub
Type: New feature | Status: assigned

Component: Database layer | Version: 2.1
(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 Ubadub):

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


Comment:

Assuming the ticket refers only to errors of the form
{{{django.core.exceptions.FieldError: Unsupported lookup
'<INCORRECT_FIELD>' for <SOME_MODEL> or join on the field not
permitted.}}}, I believe I can add this feature, so I am assigning the
ticket to myself.

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

Django

unread,
Sep 29, 2018, 4:22:35 AM9/29/18
to django-...@googlegroups.com
#29804: Add 'Did you mean' suggestions for unsupported lookup error
-------------------------------------+-------------------------------------
Reporter: Rich Jones | Owner: Abhinav
| Patil

Type: New feature | Status: assigned
Component: Database layer | Version: 2.1
(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 Abhinav Patil):

I've submitted a pull request here:
https://github.com/django/django/pull/10457

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

Django

unread,
Sep 29, 2018, 4:25:32 AM9/29/18
to django-...@googlegroups.com
#29804: Add 'Did you mean' suggestions for unsupported lookup error
-------------------------------------+-------------------------------------
Reporter: Rich Jones | Owner: Abhinav
| Patil
Type: New feature | Status: assigned
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Abhinav Patil):

* stage: Accepted => Ready for checkin


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

Django

unread,
Sep 29, 2018, 4:26:07 AM9/29/18
to django-...@googlegroups.com
#29804: Add 'Did you mean' suggestions for unsupported lookup error
-------------------------------------+-------------------------------------
Reporter: Rich Jones | Owner: Abhinav
| Patil
Type: New feature | Status: assigned
Component: Database layer | Version: 2.1
(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 Abhinav Patil):

* stage: Ready for checkin => Accepted


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

Django

unread,
Sep 29, 2018, 6:32:10 AM9/29/18
to django-...@googlegroups.com
#29804: Add 'Did you mean' suggestions for unsupported lookup error
-------------------------------------+-------------------------------------
Reporter: Rich Jones | Owner: Abhinav
| Patil
Type: New feature | Status: assigned
Component: Database layer | Version: 2.1
(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 Claude Paroz):

* has_patch: 0 => 1


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

Django

unread,
Sep 29, 2018, 9:40:39 PM9/29/18
to django-...@googlegroups.com
#29804: Add 'Did you mean' suggestions for unsupported lookup error
-------------------------------------+-------------------------------------
Reporter: Rich Jones | Owner: Abhinav
| Patil
Type: New feature | Status: assigned
Component: Database layer | Version: 2.1
(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
-------------------------------------+-------------------------------------

Comment (by Abhinav Patil):

This is my first patch, so forgive me for what is probably a silly
question, and I couldn't find anything concrete answering my question in
the docs... anyways, the question: what happens now? Is there a process
for getting this patch reviewed or is it along the lines of "just wait and
someone will do it eventually"?

--
Ticket URL: <https://code.djangoproject.com/ticket/29804#comment:8>

Django

unread,
Oct 1, 2018, 7:23:26 PM10/1/18
to django-...@googlegroups.com
#29804: Add 'Did you mean' suggestions for unsupported lookup error
-------------------------------------+-------------------------------------
Reporter: Rich Jones | Owner: Abhinav
| Patil
Type: New feature | Status: closed

Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution: fixed
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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"bf01994a5ccc07cbe4b011b53b644eba04da052e" bf01994a]:
{{{
#!CommitTicketReference repository=""
revision="bf01994a5ccc07cbe4b011b53b644eba04da052e"
Fixed #29804 -- Added 'did you mean' suggestions for unsupported lookup
error.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29804#comment:9>

Reply all
Reply to author
Forward
0 new messages