Opened 17 years ago

Closed 17 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: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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

Download all attachments as: .zip

Change History (9)

by ned@…, 17 years ago

Attachment: patch_field_choices.txt added

The patch!

comment:1 by anonymous, 17 years ago

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 by Malcolm Tredinnick, 17 years ago

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 by Karen Tracey <kmtracey@…>, 17 years ago

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.

by ned@…, 17 years ago

A second patch, fixing the tests.

comment:4 by anonymous, 17 years ago

Needs tests: unset

by Collin Grady <cgrady@…>, 17 years ago

Attachment: field_choices.patch added

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

comment:5 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedReady for checkin

comment:6 by Malcolm Tredinnick, 17 years ago

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