Django

Code

Ticket #4130 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

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

Reported by: ned@nedbatchelder.com Assigned to: adrian
Milestone: Component: Core framework
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

patch_field_choices.txt (1.3 kB) - added by ned@nedbatchelder on 04/23/07 10:22:25.
The patch!
patch_field_choices_tests.txt (3.3 kB) - added by ned@nedbatchelder on 04/23/07 14:11:41.
A second patch, fixing the tests.
field_choices.patch (4.6 kB) - added by Collin Grady <cgrady@the-magi.us> on 04/25/07 01:15:39.
updated patch to trunk, fixed paths in test patch, combined both

Change History

04/23/07 10:22:25 changed by ned@nedbatchelder

  • attachment patch_field_choices.txt added.

The patch!

04/23/07 10:22:49 changed by anonymous

  • needs_better_patch changed.
  • 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..
  • needs_tests changed.
  • needs_docs changed.

04/23/07 10:24:28 changed by mtredinnick

  • has_patch set to 1.
  • 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).

04/23/07 11:34:16 changed by Karen Tracey <kmtracey@gmail.com>

  • needs_tests set to 1.

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.

04/23/07 14:11:41 changed by ned@nedbatchelder

  • attachment patch_field_choices_tests.txt added.

A second patch, fixing the tests.

04/23/07 14:12:04 changed by anonymous

  • needs_tests deleted.

04/25/07 01:15:39 changed by Collin Grady <cgrady@the-magi.us>

  • attachment field_choices.patch added.

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

04/29/07 22:36:12 changed by Simon G. <dev@simon.net.nz>

  • stage changed from Unreviewed to Ready for checkin.

04/30/07 22:21:54 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(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/Change #4130 (When mistyping a field name in an ORM call, the error message could be a lot more helpful.)




Change Properties
Action