Code

Opened 7 years ago

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

Download all attachments as: .zip

Change History (9)

Changed 7 years ago by ned@…

The patch!

comment:1 Changed 7 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from When mistyping a field name in an ORM call, the error message could be a lot more helpful. to [patch] When mistyping a field name in an ORM call, the error message could be a lot more helpful.

comment:2 Changed 7 years ago by mtredinnick

  • Has patch set
  • Summary changed from [patch] When mistyping a field name in an ORM call, the error message could be a lot more helpful. to 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 7 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 7 years ago by ned@…

A second patch, fixing the tests.

comment:4 Changed 7 years ago by anonymous

  • Needs tests unset

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

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

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

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:6 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.