diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2009-03-31 20:39:54 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2009-03-31 20:39:54 +0000 |
| commit | 00087ef006ecbebf34c67d7d15c27a61024ce0da (patch) | |
| tree | 157c07c5535a21fd98ef2848639ec9ddb3ef25c4 /django | |
| parent | 1e0acd537b087978162750ad908e564cecf3301c (diff) | |
[1.0.X] Fixed #9863. A ForeignKey with editable=False to the parent in an inline no longer raises an exception. Thanks to keithb for the test case and Alex Gaynor for the patch. Backport of r10239 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10287 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/forms/models.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/forms/models.py b/django/forms/models.py index a3c8f355a4..57dca31fca 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -519,7 +519,11 @@ class BaseInlineFormSet(BaseModelFormSet): if self._pk_field == self.fk: form.fields[self._pk_field.name] = InlineForeignKeyField(self.instance, pk_field=True) else: - form.fields[self.fk.name] = InlineForeignKeyField(self.instance, label=form.fields[self.fk.name].label) + # The foreign key field might not be on the form, so we poke at the + # Model field to get the label, since we need that for error messages. + form.fields[self.fk.name] = InlineForeignKeyField(self.instance, + label=getattr(form.fields.get(self.fk.name), 'label', capfirst(self.fk.verbose_name)) + ) def _get_foreign_key(parent_model, model, fk_name=None): """ |
