diff options
| author | Brian Rosner <brosner@gmail.com> | 2008-07-17 16:48:27 +0000 |
|---|---|---|
| committer | Brian Rosner <brosner@gmail.com> | 2008-07-17 16:48:27 +0000 |
| commit | 1eed9b076c28f3cd1720743cfff5a31fcb5aef5d (patch) | |
| tree | 9be58059575b3c94c8ad570d6f6a66f4a54cb10a /tests/regressiontests/modeladmin/models.py | |
| parent | 81b185319c86d4770af88a6781cbbfcd1def7ab5 (diff) | |
newforms-admin: Fixed #7790 -- Check form fields, not model fields when testing for field existence in fields and fieldsets. Thanks Rozza for catching this and writing an initial patch.
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7943 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/modeladmin/models.py')
| -rw-r--r-- | tests/regressiontests/modeladmin/models.py | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/tests/regressiontests/modeladmin/models.py b/tests/regressiontests/modeladmin/models.py index 5cd27dd3c1..17e3974e1c 100644 --- a/tests/regressiontests/modeladmin/models.py +++ b/tests/regressiontests/modeladmin/models.py @@ -332,7 +332,7 @@ ImproperlyConfigured: `fields` key is required in ValidationTestModelAdmin.field >>> validate(ValidationTestModelAdmin, ValidationTestModel) Traceback (most recent call last): ... -ImproperlyConfigured: `ValidationTestModelAdmin.fieldsets[0][1]['fields']` refers to field `non_existent_field` that is missing from model `ValidationTestModel`. +ImproperlyConfigured: `ValidationTestModelAdmin.fieldsets[0][1]['fields']` refers to field `non_existent_field` that is missing from the form. >>> class ValidationTestModelAdmin(ModelAdmin): ... fieldsets = (("General", {"fields": ("name",)}),) @@ -357,6 +357,58 @@ Traceback (most recent call last): ... ImproperlyConfigured: ValidationTestModelAdmin.form does not inherit from BaseModelForm. +# fielsets with custom form + +>>> class BandAdmin(ModelAdmin): +... fieldsets = ( +... ('Band', { +... 'fields': ('non_existent_field',) +... }), +... ) +>>> validate(BandAdmin, Band) +Traceback (most recent call last): +... +ImproperlyConfigured: `BandAdmin.fieldsets[0][1]['fields']` refers to field `non_existent_field` that is missing from the form. + +>>> class BandAdmin(ModelAdmin): +... fieldsets = ( +... ('Band', { +... 'fields': ('name',) +... }), +... ) +>>> validate(BandAdmin, Band) + +>>> class AdminBandForm(forms.ModelForm): +... class Meta: +... model = Band +>>> class BandAdmin(ModelAdmin): +... form = AdminBandForm +... +... fieldsets = ( +... ('Band', { +... 'fields': ('non_existent_field',) +... }), +... ) +>>> validate(BandAdmin, Band) +Traceback (most recent call last): +... +ImproperlyConfigured: `BandAdmin.fieldsets[0][1]['fields']` refers to field `non_existent_field` that is missing from the form. + +>>> class AdminBandForm(forms.ModelForm): +... delete = forms.BooleanField() +... +... class Meta: +... model = Band +>>> class BandAdmin(ModelAdmin): +... form = AdminBandForm +... +... fieldsets = ( +... ('Band', { +... 'fields': ('name', 'bio', 'sign_date', 'delete') +... }), +... ) +>>> validate(BandAdmin, Band) + # filter_vertical >>> class ValidationTestModelAdmin(ModelAdmin): @@ -736,7 +788,7 @@ ImproperlyConfigured: `ValidationTestInline.fields` must be a list or tuple. >>> validate(ValidationTestModelAdmin, ValidationTestModel) Traceback (most recent call last): ... -ImproperlyConfigured: `ValidationTestInline.fields` refers to field `non_existent_field` that is missing from model `ValidationTestInlineModel`. +ImproperlyConfigured: `ValidationTestInline.fields` refers to field `non_existent_field` that is missing from the form. # fk_name |
