Opened 10 years ago

Closed 10 years ago

#23697 closed Cleanup/optimization (fixed)

Confusing exception raised upon unknown field in queryset filter argument

Reported by: Markus Bertheau Owned by: Michael Blatherwick
Component: Database layer (models, ORM) Version: 1.7
Severity: Normal 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

Choice.objects.filter(question__qestion_text__icontains='foo')
#################### typo here: ^^

raises

  File "/home/markus/src/django/django/db/models/sql/query.py", line 1181, in build_filter
    lookups, value)
  File "/home/markus/src/django/django/db/models/fields/related.py", line 1514, in get_lookup_constraint
    raise exceptions.FieldError('Relation fields do not support nested lookups')
FieldError: Relation fields do not support nested lookups

Which is very confusing. Is a better error message possible?

(This might have been the original cause of #23351.)

Change History (7)

comment:1 by Anssi Kääriäinen, 10 years ago

Triage Stage: UnreviewedAccepted

Better error messages are always welcome. I believe we could throw away the current error message and instead tell the user which fields are available. This would match pre-1.7 error message.

comment:2 by Tim Graham, 10 years ago

Component: UncategorizedDatabase layer (models, ORM)
Type: UncategorizedCleanup/optimization

comment:3 by Simon Charette, 10 years ago

#23351 was a duplicate which manifested itself in the admins search_fields references.

comment:4 by Michael Blatherwick, 10 years ago

Owner: changed from nobody to Michael Blatherwick
Status: newassigned

comment:6 by Paul Hallett, 10 years ago

Triage Stage: AcceptedReady for checkin

Looks good.

comment:7 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 00e66772:

Fixed #23697 -- Improved ForeignObject.get_lookup_constraint() error message.

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