Ticket #4130: field_choices.patch
File field_choices.patch, 4.6 KB (added by , 18 years ago) |
---|
-
django/db/models/query.py
853 853 return None 854 854 return matches[0] 855 855 856 def field_choices(field_list, related_query): 857 if related_query: 858 choices = [f.field.related_query_name() for f in field_list] 859 else: 860 choices = [f.name for f in field_list] 861 return choices 862 856 863 def lookup_inner(path, lookup_type, value, opts, table, column): 857 864 qn = backend.quote_name 858 865 joins, where, params = SortedDict(), [], [] … … 937 944 except FieldFound: # Match found, loop has been shortcut. 938 945 pass 939 946 else: # No match found. 940 raise TypeError, "Cannot resolve keyword '%s' into field" % name 947 choices = field_choices(current_opts.many_to_many, False) + \ 948 field_choices(current_opts.get_all_related_many_to_many_objects(), True) + \ 949 field_choices(current_opts.get_all_related_objects(), True) + \ 950 field_choices(current_opts.fields, False) 951 raise TypeError, "Cannot resolve keyword '%s' into field, choices are: %s" % (name, ", ".join(choices)) 941 952 942 953 # Check whether an intermediate join is required between current_table 943 954 # and new_table. -
tests/modeltests/reverse_lookup/models.py
55 55 >>> Poll.objects.get(choice__name__exact="This is the answer") 56 56 Traceback (most recent call last): 57 57 ... 58 TypeError: Cannot resolve keyword 'choice' into field 58 TypeError: Cannot resolve keyword 'choice' into field, choices are: poll_choice, related_choice, id, question, creator 59 59 """} -
tests/modeltests/lookup/models.py
223 223 >>> Article.objects.filter(pub_date_year='2005').count() 224 224 Traceback (most recent call last): 225 225 ... 226 TypeError: Cannot resolve keyword 'pub_date_year' into field 226 TypeError: Cannot resolve keyword 'pub_date_year' into field, choices are: id, headline, pub_date 227 227 228 228 >>> Article.objects.filter(headline__starts='Article') 229 229 Traceback (most recent call last): 230 230 ... 231 TypeError: Cannot resolve keyword 'headline__starts' into field 231 TypeError: Cannot resolve keyword 'headline__starts' into field, choices are: id, headline, pub_date 232 232 233 233 """} -
tests/modeltests/many_to_one/models.py
174 174 >>> Article.objects.filter(reporter_id__exact=1) 175 175 Traceback (most recent call last): 176 176 ... 177 TypeError: Cannot resolve keyword 'reporter_id' into field 177 TypeError: Cannot resolve keyword 'reporter_id' into field, choices are: id, headline, pub_date, reporter 178 178 179 179 # You need to specify a comparison clause 180 180 >>> Article.objects.filter(reporter_id=1) 181 181 Traceback (most recent call last): 182 182 ... 183 TypeError: Cannot resolve keyword 'reporter_id' into field 183 TypeError: Cannot resolve keyword 'reporter_id' into field, choices are: id, headline, pub_date, reporter 184 184 185 185 # You can also instantiate an Article by passing 186 186 # the Reporter's ID instead of a Reporter object. -
tests/modeltests/custom_columns/models.py
71 71 >>> Author.objects.filter(firstname__exact='John') 72 72 Traceback (most recent call last): 73 73 ... 74 TypeError: Cannot resolve keyword 'firstname' into field 74 TypeError: Cannot resolve keyword 'firstname' into field, choices are: article, id, first_name, last_name 75 75 76 76 >>> a = Author.objects.get(last_name__exact='Smith') 77 77 >>> a.first_name -
tests/regressiontests/null_queries/models.py
32 32 >>> Choice.objects.filter(foo__exact=None) 33 33 Traceback (most recent call last): 34 34 ... 35 TypeError: Cannot resolve keyword 'foo' into field 35 TypeError: Cannot resolve keyword 'foo' into field, choices are: id, poll, choice 36 36 37 37 # Can't use None on anything other than __exact 38 38 >>> Choice.objects.filter(id__gt=None)