diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-11-13 12:34:41 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-11-13 12:34:41 +0000 |
| commit | dd045aaab5cb5c5e04c5fafc62913acccf7029b3 (patch) | |
| tree | 282a6dd79b20700383d31f33d696d53e81aa58e3 /tests/regressiontests/admin_validation/models.py | |
| parent | c8514b570bb51347c2b3ffbc1df543ac2dfc7000 (diff) | |
Fixed #12209 -- Made the through attribute on a m2m relation into a property to ensure that the fully resolved through model is always provdided. Thanks to dgouldin for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11736 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_validation/models.py')
| -rw-r--r-- | tests/regressiontests/admin_validation/models.py | 27 |
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) + """} |
