diff --git a/django/forms/models.py b/django/forms/models.py
index 32a85c5..cc8bea5 100644
a
|
b
|
class BaseInlineFormSet(BaseModelFormSet):
|
545 | 545 | if self._pk_field == self.fk: |
546 | 546 | form.fields[self._pk_field.name] = InlineForeignKeyField(self.instance, pk_field=True) |
547 | 547 | else: |
548 | | form.fields[self.fk.name] = InlineForeignKeyField(self.instance, label=form.fields[self.fk.name].label) |
| 548 | # the foreign key field might not be on the form, so we poke at the |
| 549 | # Model Field to get the label, since we need that for error messages |
| 550 | form.fields[self.fk.name] = InlineForeignKeyField(self.instance, |
| 551 | label=getattr(form.fields.get(self.fk.name), 'label', capfirst(self.fk.verbose_name)) |
| 552 | ) |
549 | 553 | |
550 | 554 | def _get_foreign_key(parent_model, model, fk_name=None): |
551 | 555 | """ |
diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py
index 3546463..b4e64cf 100644
a
|
b
|
class PodcastAdmin(admin.ModelAdmin):
|
248 | 248 | |
249 | 249 | ordering = ('name',) |
250 | 250 | |
| 251 | class Parent(models.Model): |
| 252 | name = models.CharField(max_length = 128, db_index = True) |
| 253 | |
| 254 | class Child(models.Model): |
| 255 | parent = models.ForeignKey(Parent, related_name = 'child_set', editable = False) |
| 256 | name = models.CharField(max_length = 30, blank = True) |
| 257 | |
| 258 | class ChildInline(admin.StackedInline): |
| 259 | model = Child |
| 260 | extra = 10 |
| 261 | |
| 262 | class ParentAdmin(admin.ModelAdmin): |
| 263 | model = Parent |
| 264 | inlines = [ |
| 265 | ChildInline, |
| 266 | ] |
| 267 | |
251 | 268 | admin.site.register(Article, ArticleAdmin) |
252 | 269 | admin.site.register(CustomArticle, CustomArticleAdmin) |
253 | 270 | admin.site.register(Section, inlines=[ArticleInline]) |
… |
… |
admin.site.register(Persona, PersonaAdmin)
|
259 | 276 | admin.site.register(Subscriber, SubscriberAdmin) |
260 | 277 | admin.site.register(ExternalSubscriber, ExternalSubscriberAdmin) |
261 | 278 | admin.site.register(Podcast, PodcastAdmin) |
| 279 | admin.site.register(Parent, ParentAdmin) |
262 | 280 | |
263 | 281 | # We intentionally register Promo and ChapterXtra1 but not Chapter nor ChapterXtra2. |
264 | 282 | # That way we cover all four cases: |
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 2fd4c07..d42be66 100644
a
|
b
|
class AdminActionsTest(TestCase):
|
946 | 946 | } |
947 | 947 | response = self.client.post('/test_admin/admin/admin_views/externalsubscriber/', action_data) |
948 | 948 | self.failUnlessEqual(response.status_code, 302) |
| 949 | |
| 950 | class TestInlineNotEditable(TestCase): |
| 951 | fixtures = ['admin-views-users.xml', ] |
| 952 | |
| 953 | def setUp(self): |
| 954 | result = self.client.login(username='super', password='secret') |
| 955 | self.failUnlessEqual(result, True) |
| 956 | |
| 957 | def tearDown(self): |
| 958 | self.client.logout() |
| 959 | |
| 960 | def test(self): |
| 961 | """ |
| 962 | InlineModelAdmin broken? |
| 963 | """ |
| 964 | response = self.client.get('/test_admin/admin/admin_views/parent/add/') |
| 965 | self.failUnlessEqual(response.status_code, 200) |