diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
index 389692d..274a6d6 100644
a
|
b
|
def generic_inlineformset_factory(model, form=ModelForm,
|
382 | 382 | exclude.extend([ct_field.name, fk_field.name]) |
383 | 383 | else: |
384 | 384 | exclude = [ct_field.name, fk_field.name] |
| 385 | if hasattr(form, 'Meta') and hasattr(form.Meta, 'exclude'): |
| 386 | exclude.extend(list(form.Meta.exclude)) |
| 387 | |
385 | 388 | FormSet = modelformset_factory(model, form=form, |
386 | 389 | formfield_callback=formfield_callback, |
387 | 390 | formset=formset, |
diff --git a/tests/regressiontests/generic_inline_admin/models.py b/tests/regressiontests/generic_inline_admin/models.py
index fb6363e..205124f 100644
a
|
b
|
from django.db import models
|
2 | 2 | from django.contrib import admin |
3 | 3 | from django.contrib.contenttypes import generic |
4 | 4 | from django.contrib.contenttypes.models import ContentType |
| 5 | from django.forms.models import ModelForm |
5 | 6 | |
6 | 7 | class Episode(models.Model): |
7 | 8 | name = models.CharField(max_length=100) |
… |
… |
class MediaExcludeInline(generic.GenericTabularInline):
|
73 | 74 | admin.site.register(EpisodeExclude, inlines=[MediaExcludeInline]) |
74 | 75 | |
75 | 76 | # |
| 77 | # Generic inline with modelform and exclude |
| 78 | # |
| 79 | |
| 80 | class Sitcom(Episode): |
| 81 | pass |
| 82 | |
| 83 | class MediaForm(ModelForm): |
| 84 | class Meta: |
| 85 | model = Media |
| 86 | exclude = ('url',) |
| 87 | |
| 88 | class MediaInline(generic.GenericTabularInline): |
| 89 | form = MediaForm |
| 90 | model = Media |
| 91 | extra = 1 |
| 92 | |
| 93 | class SitcomAdmin(admin.ModelAdmin): |
| 94 | inlines = (MediaInline, ) |
| 95 | |
| 96 | admin.site.register(Sitcom, SitcomAdmin) |
| 97 | |
| 98 | |
| 99 | # |
76 | 100 | # Generic inline with unique_together |
77 | 101 | # |
78 | 102 | |
diff --git a/tests/regressiontests/generic_inline_admin/tests.py b/tests/regressiontests/generic_inline_admin/tests.py
index 00badc9..081474d 100644
a
|
b
|
from django.test import TestCase
|
7 | 7 | |
8 | 8 | # local test models |
9 | 9 | from models import (Episode, EpisodeExtra, EpisodeMaxNum, EpisodeExclude, |
10 | | Media, MediaInline, EpisodePermanent, MediaPermanentInline, Category) |
| 10 | Media, MediaInline, EpisodePermanent, MediaPermanentInline, Category, |
| 11 | Sitcom) |
11 | 12 | |
12 | 13 | |
13 | 14 | class GenericAdminViewTest(TestCase): |
… |
… |
class GenericInlineAdminParametersTest(TestCase):
|
182 | 183 | formset = response.context['inline_admin_formsets'][0].formset |
183 | 184 | self.assertFalse('url' in formset.forms[0], 'The formset has excluded "url" field.') |
184 | 185 | |
| 186 | def testModelFormExcludeParam(self): |
| 187 | """ |
| 188 | Generic inline formsets should respect exclude on model forms. |
| 189 | """ |
| 190 | e = self._create_object(Sitcom) |
| 191 | response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/sitcom/%s/' % e.pk) |
| 192 | formset = response.context['inline_admin_formsets'][0].formset |
| 193 | self.assertFalse('url' in formset.forms[0].fields, 'The formset has excluded "url" field.') |
| 194 | |
185 | 195 | class GenericInlineAdminWithUniqueTogetherTest(TestCase): |
186 | 196 | fixtures = ['users.xml'] |
187 | 197 | |