diff options
author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-05-05 09:53:50 +0000 |
---|---|---|
committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-05-05 09:53:50 +0000 |
commit | dcc8577969aeef3726e38efb28dbce459ff3a9ba (patch) | |
tree | ecd97c6fe9064276fd7c3b5007f97397cb5e60f7 /django/db | |
parent | 63d95548a76a47c88c9a06197057e0715b83393e (diff) | |
download | django-dcc8577969aeef3726e38efb28dbce459ff3a9ba.tar.gz |
unicode: Merged from trunk up to [5150].
git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5151 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db')
-rw-r--r-- | django/db/models/fields/__init__.py | 6 | ||||
-rw-r--r-- | django/db/models/query.py | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 77cac7745c..350ffc99f5 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -869,6 +869,12 @@ class USStateField(Field): def get_manipulator_field_objs(self): return [oldforms.USStateField] + def formfield(self, **kwargs): + from django.contrib.localflavor.us.forms import USStateSelect + defaults = {'widget': USStateSelect} + defaults.update(kwargs) + return super(USStateField, self).formfield(**defaults) + class XMLField(TextField): def __init__(self, verbose_name=None, name=None, schema_path=None, **kwargs): self.schema_path = schema_path diff --git a/django/db/models/query.py b/django/db/models/query.py index 91f54e48b9..06163677d4 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -853,6 +853,13 @@ def find_field(name, field_list, related_query): 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(), [], [] @@ -937,7 +944,11 @@ def lookup_inner(path, lookup_type, value, opts, table, column): 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. |