summaryrefslogtreecommitdiff
path: root/tests/regressiontests/admin_validation/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regressiontests/admin_validation/models.py')
-rw-r--r--tests/regressiontests/admin_validation/models.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_validation/models.py b/tests/regressiontests/admin_validation/models.py
index 5506114841..93e3e065e6 100644
--- a/tests/regressiontests/admin_validation/models.py
+++ b/tests/regressiontests/admin_validation/models.py
@@ -26,6 +26,19 @@ class TwoAlbumFKAndAnE(models.Model):
e = models.CharField(max_length=1)
+class Author(models.Model):
+ name = models.CharField(max_length=100)
+
+
+class Book(models.Model):
+ name = models.CharField(max_length=100)
+ authors = models.ManyToManyField(Author, through='AuthorsBooks')
+
+
+class AuthorsBooks(models.Model):
+ author = models.ForeignKey(Author)
+ book = models.ForeignKey(Book)
+
__test__ = {'API_TESTS':"""
@@ -95,4 +108,18 @@ Exception: <class 'regressiontests.admin_validation.models.TwoAlbumFKAndAnE'> ha
>>> validate_inline(TwoAlbumFKAndAnEInline, None, Album)
+# Regression test for #12203 -- If the explicitly provided through model
+# is specified as a string, the admin should still be able use
+# Model.m2m_field.through
+
+>>> class AuthorsInline(admin.TabularInline):
+... model = Book.authors.through
+
+>>> class BookAdmin(admin.ModelAdmin):
+... inlines = [AuthorsInline]
+
+# If the through model is still a string (and hasn't been resolved to a model)
+# the validation will fail.
+>>> validate(BookAdmin, Book)
+
"""}