diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-04-22 15:48:51 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-04-22 15:48:51 +0000 |
| commit | 6c15b5db6014a7dadb0c237e689bdaed4761fb16 (patch) | |
| tree | 88ef48e22dee3f86b3ebd8982b5f839977187a4a /tests/regressiontests/modeladmin | |
| parent | 71233bcdf3c90098531901da4e380165ed0059d4 (diff) | |
Fixed #10208: `ModelAdmin` now respects the `exclude` and `field` atributes of custom `ModelForm`s. Thanks, Alex Gaynor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10619 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/modeladmin')
| -rw-r--r-- | tests/regressiontests/modeladmin/models.py | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/regressiontests/modeladmin/models.py b/tests/regressiontests/modeladmin/models.py index 3a7d3f031f..ef05b5a048 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,46 @@ 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) +>>> ma.get_form(request).base_fields.keys() +['main_band', 'opening_band', 'day'] + +>>> class AdminConcertForm(forms.ModelForm): +... extra = forms.CharField() +... class Meta: +... model = Concert +... fields = ['extra', 'transport'] + +>>> class ConcertAdmin(ModelAdmin): +... form = AdminConcertForm + +>>> ma = ConcertAdmin(Concert, site) +>>> ma.get_form(request).base_fields.keys() +['extra', 'transport'] + +>>> class ConcertInline(TabularInline): +... form = AdminConcertForm +... model = Concert +... fk_name = 'main_band' + +>>> class BandAdmin(ModelAdmin): +... inlines = [ +... ConcertInline +... ] + +>>> ma = BandAdmin(Band, site) +>>> list(ma.get_formsets(request))[0]().forms[0].fields.keys() +['extra', 'transport', 'id', 'DELETE', 'main_band'] + + >>> band.delete() # ModelAdmin Option Validation ################################################ |
