Opened 10 years ago

Closed 10 years ago

#4130 closed (fixed)

When mistyping a field name in an ORM call, the error message could be a lot more helpful.

Reported by: ned@… Owned by: Adrian Holovaty
Component: Core (Other) Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If I make a mistake when creating a filter call, the error message simply says, "Cannot resolve keyword 'pollls' into field".

More helpful is to show what the possible fields are: "Cannot resolve keyword 'pollls' into field, choices are: polls, cats, dogs"

Attached is a patch that changes the message in this way.

Attachments (3)

patch_field_choices.txt (1.3 KB) - added by ned@… 10 years ago.
The patch!
patch_field_choices_tests.txt (3.3 KB) - added by ned@… 10 years ago.
A second patch, fixing the tests.
field_choices.patch (4.6 KB) - added by Collin Grady <cgrady@…> 10 years ago.
updated patch to trunk, fixed paths in test patch, combined both

Download all attachments as: .zip

Change History (9)

Changed 10 years ago by ned@…

Attachment: patch_field_choices.txt added

The patch!

comment:1 Changed 10 years ago by anonymous

Summary: When mistyping a field name in an ORM call, the error message could be a lot more helpful.[patch] When mistyping a field name in an ORM call, the error message could be a lot more helpful.

comment:2 Changed 10 years ago by Malcolm Tredinnick

Has patch: set
Summary: [patch] When mistyping a field name in an ORM call, the error message could be a lot more helpful.When mistyping a field name in an ORM call, the error message could be a lot more helpful.

anonymous: Please don't change titles to include the word [patch]. It wastes space. We have a checkbox for that purpose (indicating patches, not wasting space).

comment:3 Changed 10 years ago by Karen Tracey <kmtracey@…>

Needs tests: set

FYI there are a couple of tests in tests/modeltests/lookup/models.py that test for this error message. They will need to be changed if the error message changes.

Changed 10 years ago by ned@…

A second patch, fixing the tests.

comment:4 Changed 10 years ago by anonymous

Needs tests: unset

Changed 10 years ago by Collin Grady <cgrady@…>

Attachment: field_choices.patch added

updated patch to trunk, fixed paths in test patch, combined both

comment:5 Changed 10 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedReady for checkin

comment:6 Changed 10 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [5133]) Fixed #4130 -- Added more self-explanatory error message when a typo is made in
a queryset field argument.

We may need to fine-tune the error message based on experience down the line,
but this stands as an improvement on its own. Thanks, Ned Batchelder.

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