1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

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.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10239 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans
2009-03-31 00:03:34 +00:00
parent 5c9d54344c
commit 62353e8fe7
3 changed files with 37 additions and 1 deletions

View File

@@ -545,7 +545,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):
"""