summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-04-22 16:14:02 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-04-22 16:14:02 +0000
commit421b22e8eed0094669f6b197ac52bace5b5f29d9 (patch)
tree716c4b5579988bb93ebf74ff90fd61b0aaced7ef /tests
parentcb92893598a31bf3af697d65e257a33f6686d6a2 (diff)
[1.0.X] Fixed #10208: `ModelAdmin` now respects the `exclude` and `field` atributes of custom `ModelForm`s. Thanks, Alex Gaynor. Backport of r10619 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10620 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/modeladmin/models.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/tests/regressiontests/modeladmin/models.py b/tests/regressiontests/modeladmin/models.py
index 3a7d3f031f..931a5a6af7 100644
--- a/tests/regressiontests/modeladmin/models.py
+++ b/tests/regressiontests/modeladmin/models.py
@@ -37,7 +37,7 @@ class ValidationTestInlineModel(models.Model):
__test__ = {'API_TESTS': """
->>> from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
+>>> from django.contrib.admin.options import ModelAdmin, TabularInline, HORIZONTAL, VERTICAL
>>> from django.contrib.admin.sites import AdminSite
None of the following tests really depend on the content of the request, so
@@ -262,6 +262,51 @@ blank=True for the model field. Finally, the widget should have the
>>> list(cmafa.base_fields['transport'].widget.choices)
[('', u'None'), (1, 'Plane'), (2, 'Train'), (3, 'Bus')]
+>>> class AdminConcertForm(forms.ModelForm):
+... class Meta:
+... model = Concert
+... exclude = ('transport',)
+
+>>> class ConcertAdmin(ModelAdmin):
+... form = AdminConcertForm
+
+>>> ma = ConcertAdmin(Concert, site)
+>>> ks = ma.get_form(request).base_fields.keys()
+>>> ks.sort()
+>>> ks
+['day', 'main_band', 'opening_band']
+
+>>> class AdminConcertForm(forms.ModelForm):
+... extra = forms.CharField()
+... class Meta:
+... model = Concert
+... fields = ['extra', 'transport']
+
+>>> class ConcertAdmin(ModelAdmin):
+... form = AdminConcertForm
+
+>>> ma = ConcertAdmin(Concert, site)
+>>> ks = ma.get_form(request).base_fields.keys()
+>>> ks.sort()
+>>> ks
+['extra', 'transport']
+
+>>> class ConcertInline(TabularInline):
+... form = AdminConcertForm
+... model = Concert
+... fk_name = 'main_band'
+
+>>> class BandAdmin(ModelAdmin):
+... inlines = [
+... ConcertInline
+... ]
+
+>>> ma = BandAdmin(Band, site)
+>>> ks = list(ma.get_formsets(request))[0]().forms[0].fields.keys()
+>>> ks.sort()
+>>> ks
+['DELETE', 'extra', 'id', 'main_band', 'transport']
+
>>> band.delete()
# ModelAdmin Option Validation ################################################