summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorBrian Rosner <brosner@gmail.com>2009-10-19 19:17:20 +0000
committerBrian Rosner <brosner@gmail.com>2009-10-19 19:17:20 +0000
commitcb7a3262b5be1d9093a694b1619df6c4cdff0035 (patch)
treee5385b36d13ecc24a1cab7ba956e2c289ad510b1 /tests/regressiontests
parent5fc35c9caf73a038607c53393aff797f6e8e395a (diff)
Moved the call to _get_foreign_key to run in all cases catching incorrect inline setup sooner.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11631 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/admin_validation/models.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/regressiontests/admin_validation/models.py b/tests/regressiontests/admin_validation/models.py
index 08d8d94b4f..5506114841 100644
--- a/tests/regressiontests/admin_validation/models.py
+++ b/tests/regressiontests/admin_validation/models.py
@@ -20,7 +20,7 @@ class Song(models.Model):
return self.title
-class Model11709(models.Model):
+class TwoAlbumFKAndAnE(models.Model):
album1 = models.ForeignKey(Album, related_name="album1_set")
album2 = models.ForeignKey(Album, related_name="album2_set")
e = models.CharField(max_length=1)
@@ -72,11 +72,27 @@ ImproperlyConfigured: SongInline cannot exclude the field 'album' - this is the
# 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
+>>> class TwoAlbumFKAndAnEInline(admin.TabularInline):
+... model = TwoAlbumFKAndAnE
... exclude = ("e",)
... fk_name = "album1"
->>> validate_inline(Model11709Inline, None, Album)
+>>> validate_inline(TwoAlbumFKAndAnEInline, None, Album)
+
+# Ensure inlines validate that they can be used correctly.
+
+>>> class TwoAlbumFKAndAnEInline(admin.TabularInline):
+... model = TwoAlbumFKAndAnE
+
+>>> validate_inline(TwoAlbumFKAndAnEInline, None, Album)
+Traceback (most recent call last):
+ ...
+Exception: <class 'regressiontests.admin_validation.models.TwoAlbumFKAndAnE'> has more than 1 ForeignKey to <class 'regressiontests.admin_validation.models.Album'>
+
+>>> class TwoAlbumFKAndAnEInline(admin.TabularInline):
+... model = TwoAlbumFKAndAnE
+... fk_name = "album1"
+
+>>> validate_inline(TwoAlbumFKAndAnEInline, None, Album)
"""}