diff options
| author | Brian Rosner <brosner@gmail.com> | 2009-10-19 19:17:07 +0000 |
|---|---|---|
| committer | Brian Rosner <brosner@gmail.com> | 2009-10-19 19:17:07 +0000 |
| commit | 5fc35c9caf73a038607c53393aff797f6e8e395a (patch) | |
| tree | 6a340aceb152cc8b79200cbdd99992eaad834018 /tests/regressiontests/admin_validation/models.py | |
| parent | 69535b7b1383c6d74fac4f5a1b1a89c2c9956e23 (diff) | |
Fixed #11709 — Pass inline fk_name attribute when grabbing foreign key to test for exclusion. Thanks yishaibeeri for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11630 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_validation/models.py')
| -rw-r--r-- | tests/regressiontests/admin_validation/models.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/regressiontests/admin_validation/models.py b/tests/regressiontests/admin_validation/models.py index 1ff89e2502..08d8d94b4f 100644 --- a/tests/regressiontests/admin_validation/models.py +++ b/tests/regressiontests/admin_validation/models.py @@ -4,9 +4,11 @@ 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) @@ -17,11 +19,19 @@ class Song(models.Model): def __unicode__(self): return self.title + +class Model11709(models.Model): + album1 = models.ForeignKey(Album, related_name="album1_set") + album2 = models.ForeignKey(Album, related_name="album2_set") + e = models.CharField(max_length=1) + + + __test__ = {'API_TESTS':""" >>> from django import forms >>> from django.contrib import admin ->>> from django.contrib.admin.validation import validate +>>> from django.contrib.admin.validation import validate, validate_inline # Regression test for #8027: custom ModelForms with fields/fieldsets @@ -58,4 +68,15 @@ Traceback (most recent call last): ... ImproperlyConfigured: SongInline cannot exclude the field 'album' - this is the foreign key to the parent model Album. +# Regression test for #11709 - when testing for fk excluding (when exclude is +# given) make sure fk_name is honored or things blow up when there is more +# than one fk to the parent model. + +>>> class Model11709Inline(admin.TabularInline): +... model = Model11709 +... exclude = ("e",) +... fk_name = "album1" + +>>> validate_inline(Model11709Inline, None, Album) + """} |
