diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-08-28 15:43:04 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-08-28 15:43:04 +0000 |
| commit | b31568aed34d8728c153ba4e722b7018f2667351 (patch) | |
| tree | 156711ea0619144312381a321c77210ca637c09c /tests/regressiontests | |
| parent | b99cc935ebedf52111507ca92641ffde73a3d9ae (diff) | |
Fixed #8027: correctly validate fields/fieldsets in `ModelAdmin` validation when using custom `ModelForm`s.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8662 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/admin_validation/__init__.py | 0 | ||||
| -rw-r--r-- | tests/regressiontests/admin_validation/models.py | 43 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_validation/__init__.py b/tests/regressiontests/admin_validation/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/regressiontests/admin_validation/__init__.py diff --git a/tests/regressiontests/admin_validation/models.py b/tests/regressiontests/admin_validation/models.py new file mode 100644 index 0000000000..bd83f80a1b --- /dev/null +++ b/tests/regressiontests/admin_validation/models.py @@ -0,0 +1,43 @@ +""" +Tests of ModelAdmin validation logic. +""" + +from django.db import models + +class Song(models.Model): + title = models.CharField(max_length=150) + + class Meta: + ordering = ('title',) + + def __unicode__(self): + return self.title + +__test__ = {'API_TESTS':""" + +>>> from django import forms +>>> from django.contrib import admin +>>> from django.contrib.admin.validation import validate + +# +# Regression test for #8027: custom ModelForms with fields/fieldsets +# + +>>> class SongForm(forms.ModelForm): +... pass + +>>> class ValidFields(admin.ModelAdmin): +... form = SongForm +... fields = ['title'] + +>>> class InvalidFields(admin.ModelAdmin): +... form = SongForm +... fields = ['spam'] + +>>> validate(ValidFields, Song) +>>> validate(InvalidFields, Song) +Traceback (most recent call last): + ... +ImproperlyConfigured: 'InvalidFields.fields' refers to field 'spam' that is missing from the form. + +"""} |
