diff --git a/tests/regressiontests/generic_inline_admin/models.py b/tests/regressiontests/generic_inline_admin/models.py
index fb6363e..ed412bf 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 custom modelform and exclude |
| 78 | # |
| 79 | |
| 80 | class EpisodeModelFormExclude(Episode): |
| 81 | pass |
| 82 | |
| 83 | class ModelFormWithExclude(ModelForm): |
| 84 | class Meta: |
| 85 | model = Media |
| 86 | exclude = ('url',) |
| 87 | |
| 88 | class MediaWithModelFormExcludeInline(generic.GenericTabularInline): |
| 89 | form = ModelFormWithExclude |
| 90 | model = Media |
| 91 | extra = 1 |
| 92 | |
| 93 | class EpisodeModelFormExcludeAdmin(admin.ModelAdmin): |
| 94 | inlines = (MediaWithModelFormExcludeInline, ) |
| 95 | |
| 96 | admin.site.register(EpisodeModelFormExclude, EpisodeModelFormExcludeAdmin) |
| 97 | |
| 98 | # |
76 | 99 | # Generic inline with unique_together |
77 | 100 | # |
78 | 101 | |
diff --git a/tests/regressiontests/generic_inline_admin/tests.py b/tests/regressiontests/generic_inline_admin/tests.py
index c40b6dd..4a151bd 100644
a
|
b
|
from django.test import TestCase
|
6 | 6 | |
7 | 7 | # local test models |
8 | 8 | from models import Episode, EpisodeExtra, EpisodeMaxNum, EpisodeExclude, \ |
9 | | Media, EpisodePermanent, MediaPermanentInline, Category |
| 9 | EpisodeModelFormExclude, Media, EpisodePermanent, \ |
| 10 | MediaPermanentInline, Category |
10 | 11 | |
11 | 12 | |
12 | 13 | class GenericAdminViewTest(TestCase): |
… |
… |
class GenericInlineAdminParametersTest(TestCase):
|
181 | 182 | formset = response.context['inline_admin_formsets'][0].formset |
182 | 183 | self.assertFalse('url' in formset.forms[0], 'The formset has excluded "url" field.') |
183 | 184 | |
| 185 | def testModelFormExcludeParam(self): |
| 186 | """ |
| 187 | Generic inline formsets should respect exclude on custom model forms. |
| 188 | """ |
| 189 | e = self._create_object(EpisodeModelFormExclude) |
| 190 | response = self.client.get('/generic_inline_admin/admin/generic_inline_admin/episodemodelformexclude/%s/' % e.pk) |
| 191 | formset = response.context['inline_admin_formsets'][0].formset |
| 192 | self.assertFalse('url' in formset.forms[0].fields, 'The formset has excluded "url" field.') |
| 193 | |
184 | 194 | class GenericInlineAdminWithUniqueTogetherTest(TestCase): |
185 | 195 | fixtures = ['users.xml'] |
186 | 196 | |