(This is a ticket that Akismet wouldn't allow.) When I use the wrong filter keyword (for example, a typo in a field name), the error message says,
TypeError: Cannot resolve keyword 'storyitems' into field Much nicer would be to show the list of field name that can be used: TypeError: Cannot resolve keyword 'storyitem' into field, choices are: tags, event, admintag, storycomment, favorite, story, storyundo, feature, textblock, textblock, shareablelink, groupstory, textblock, storyace, invitation, storyview, page, postcard, poster, id, name, date, modified_date, template, template2, access, status, user, caption_policy, share_policy, aspect, layout, flowmode, collmode, widget, widgetstale, revision, undostate, karma, storydesign, type, label, parent, product_id This helps me get my code working faster, with less head-scratching. Attached is the patch to query.py that enables these better messages. --Ned. -- Ned Batchelder, http://nedbatchelder.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---
--- django/db/models/query.py (revision 3943) +++ django/db/models/query.py (working copy) @@ -752,12 +752,19 @@ else: matches = [f for f in field_list if f.name == name] if len(matches) != 1: return None return matches[0] +def field_choices(field_list, related_query): + if related_query: + choices = [f.field.related_query_name() for f in field_list] + else: + choices = [f.name for f in field_list] + return choices + def lookup_inner(path, lookup_type, value, opts, table, column): qn = backend.quote_name joins, where, params = SortedDict(), [], [] current_opts = opts current_table = table current_column = column @@ -830,13 +837,17 @@ raise FieldFound except FieldFound: # Match found, loop has been shortcut. pass else: # No match found. - raise TypeError, "Cannot resolve keyword '%s' into field" % name + choices = field_choices(current_opts.many_to_many, False) + \ + field_choices(current_opts.get_all_related_many_to_many_objects(), True) + \ + field_choices(current_opts.get_all_related_objects(), True) + \ + field_choices(current_opts.fields, False) + raise TypeError, "Cannot resolve keyword '%s' into field, choices are: %s" % (name, ", ".join(choices)) # Check whether an intermediate join is required between current_table # and new_table. if intermediate_table: joins[qn(current_table)] = ( qn(intermediate_table), "LEFT OUTER JOIN",