Opened 6 years ago

Closed 6 years ago

#29804 closed New feature (fixed)

Add 'Did you mean' suggestions for unsupported lookup error

Reported by: Rich Jones Owned by: Abhinav Patil
Component: Database layer (models, ORM) Version: 2.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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!

Change History (7)

comment:1 by Tim Graham, 6 years ago

Component: UncategorizedDatabase layer (models, ORM)
Summary: Add 'Did You Mean' For Common Unsupported LookupsAdd 'Did you mean' suggestions for unsupported lookup error
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

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']

comment:2 by Abhinav Patil, 6 years ago

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

comment:3 by Abhinav Patil, 6 years ago

Owner: changed from nobody to Abhinav Patil
Status: newassigned

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.

comment:4 by Abhinav Patil, 6 years ago

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

comment:7 by Claude Paroz, 6 years ago

Has patch: set

comment:8 by Abhinav Patil, 6 years ago

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"?

comment:9 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In bf01994a:

Fixed #29804 -- Added 'did you mean' suggestions for unsupported lookup error.

Note: See TracTickets for help on using tickets.
Back to Top