mirror of
https://github.com/django/django.git
synced 2025-12-01 07:48:28 +00:00
Fixed #17497 -- Corrected FieldError message in add_fields()
The erroneous message was user visible in values_list() calls. Thanks to ojii for report and review, and to antoviaque for the patch.
This commit is contained in:
parent
aeda55e6bf
commit
fcad6c48f0
2 changed files with 22 additions and 5 deletions
|
|
@ -1655,10 +1655,15 @@ class Query(object):
|
|||
except MultiJoin:
|
||||
raise FieldError("Invalid field name: '%s'" % name)
|
||||
except FieldError:
|
||||
names = opts.get_all_field_names() + self.extra.keys() + self.aggregate_select.keys()
|
||||
names.sort()
|
||||
raise FieldError("Cannot resolve keyword %r into field. "
|
||||
"Choices are: %s" % (name, ", ".join(names)))
|
||||
if name.find(LOOKUP_SEP) != -1:
|
||||
# For lookups spanning over relationships, show the error
|
||||
# from the model on which the lookup failed.
|
||||
raise
|
||||
else:
|
||||
names = sorted(opts.get_all_field_names() + self.extra.keys()
|
||||
+ self.aggregate_select.keys())
|
||||
raise FieldError("Cannot resolve keyword %r into field. "
|
||||
"Choices are: %s" % (name, ", ".join(names)))
|
||||
self.remove_inherited_models()
|
||||
|
||||
def add_ordering(self, *ordering):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue