diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-05-03 13:39:33 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-05-03 13:39:33 +0000 |
| commit | d7233e7c5adb8a885cb7265f58ef8a3baedbf8e7 (patch) | |
| tree | 2ef170aeb0496f27f0b4c89c168f12c531e2157b /tests/regressiontests/admin_validation/models.py | |
| parent | 80a54dd23bfda4bb297f9b13f2a54c1f10664cf5 (diff) | |
Fixed #9932 -- Added a validation error when an inline tries to exclude the foreign key that provides the link to the parent model. Thanks to david for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10668 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_validation/models.py')
| -rw-r--r-- | tests/regressiontests/admin_validation/models.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/regressiontests/admin_validation/models.py b/tests/regressiontests/admin_validation/models.py index bd83f80a1b..1ff89e2502 100644 --- a/tests/regressiontests/admin_validation/models.py +++ b/tests/regressiontests/admin_validation/models.py @@ -4,12 +4,16 @@ Tests of ModelAdmin validation logic. from django.db import models +class Album(models.Model): + title = models.CharField(max_length=150) + class Song(models.Model): title = models.CharField(max_length=150) - + album = models.ForeignKey(Album) + class Meta: ordering = ('title',) - + def __unicode__(self): return self.title @@ -19,9 +23,7 @@ __test__ = {'API_TESTS':""" >>> 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 @@ -40,4 +42,20 @@ Traceback (most recent call last): ... ImproperlyConfigured: 'InvalidFields.fields' refers to field 'spam' that is missing from the form. +# Regression test for #9932 - exclude in InlineModelAdmin +# should not contain the ForeignKey field used in ModelAdmin.model + +>>> class SongInline(admin.StackedInline): +... model = Song +... exclude = ['album'] + +>>> class AlbumAdmin(admin.ModelAdmin): +... model = Album +... inlines = [SongInline] + +>>> validate(AlbumAdmin, Album) +Traceback (most recent call last): + ... +ImproperlyConfigured: SongInline cannot exclude the field 'album' - this is the foreign key to the parent model Album. + """} |
