diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-11-18 07:44:06 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-11-18 07:44:06 +0000 |
| commit | bb4062d53b0caae84732c5940a97e3da1b14823f (patch) | |
| tree | a69c92a1ae4944f2711c814377379091b8b73d50 /tests/regressiontests/admin_validation | |
| parent | cd0d7e676db60dedfc231e013aa60db516831223 (diff) | |
Fixed #12237 -- Improved the error message for m2m fields with an explicit through model being listed in admin fieldsets. Thanks to Pyth for the report and Ramiro Morales for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11744 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_validation')
| -rw-r--r-- | tests/regressiontests/admin_validation/models.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/regressiontests/admin_validation/models.py b/tests/regressiontests/admin_validation/models.py index 924cf69d4d..1a34e4d30c 100644 --- a/tests/regressiontests/admin_validation/models.py +++ b/tests/regressiontests/admin_validation/models.py @@ -108,8 +108,9 @@ Exception: <class 'regressiontests.admin_validation.models.TwoAlbumFKAndAnE'> ha >>> validate_inline(TwoAlbumFKAndAnEInline, None, Album) -# Regression test for #12203 - Fail more gracefully when a M2M field that -# specifies the 'through' option is included in the 'fields' ModelAdmin option. +# Regression test for #12203/#12237 - Fail more gracefully when a M2M field that +# specifies the 'through' option is included in the 'fields' or the 'fieldsets' +# ModelAdmin options. >>> class BookAdmin(admin.ModelAdmin): ... fields = ['authors'] @@ -119,6 +120,17 @@ Traceback (most recent call last): ... ImproperlyConfigured: 'BookAdmin.fields' can't include the ManyToManyField field 'authors' because 'authors' manually specifies a 'through' model. +>>> class FieldsetBookAdmin(admin.ModelAdmin): +... fieldsets = ( +... ('Header 1', {'fields': ('name',)}), +... ('Header 2', {'fields': ('authors',)}), +... ) + +>>> validate(FieldsetBookAdmin, Book) +Traceback (most recent call last): + ... +ImproperlyConfigured: 'FieldsetBookAdmin.fieldsets[1][1]['fields']' can't include the ManyToManyField field 'authors' because 'authors' manually specifies a 'through' model. + # Regression test for #12209 -- If the explicitly provided through model # is specified as a string, the admin should still be able use # Model.m2m_field.through |
