diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-12-08 08:23:52 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-12-08 08:23:52 +0000 |
| commit | bffb45786297b11e6f189c302d084afca670709a (patch) | |
| tree | 4847194b63aef36f2edecfe5ff255c92f533ccc1 /django/forms | |
| parent | 85e1d876c0ca7967452dc8e66ce4dc14b55dea85 (diff) | |
[1.0.X] The first step in fixing a group of problems related to outputting a
proper "value" for a field that is a relation to another model.
This part adds the utility method on Model that should help in general.Also
cleans up the slightly ugly mess from r8957.
Backport of r9601 from trunk (the second piece of this patch is a bugfix, not
just a tidy-up. It looks like it might be possible to have to_field setups that
make the existing code fail and that's only hidden by the fact that inherited
models with to_field relations to the parent fail for other reasons right now).
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9603 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/models.py | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/django/forms/models.py b/django/forms/models.py index 65f20ad303..81a7439331 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -624,13 +624,7 @@ class ModelChoiceIterator(object): def choice(self, obj): if self.field.to_field_name: - # FIXME: The try..except shouldn't be necessary here. But this is - # going in just before 1.0, so I want to be careful. Will check it - # out later. - try: - key = getattr(obj, self.field.to_field_name).pk - except AttributeError: - key = getattr(obj, self.field.to_field_name) + key = obj.serializable_value(self.field.to_field_name) else: key = obj.pk return (key, self.field.label_from_instance(obj)) |
