Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

newforms-admin: Fixed #7794 -- Allow BaseModelFormSet classes to work…

… as an inline formset. This just loosens the validator checks. Thanks paltman for the report.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7942 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 81b185319c86d4770af88a6781cbbfcd1def7ab5 1 parent dce7cfe
Brian Rosner brosner authored
6 django/contrib/admin/validation.py
View
@@ -1,7 +1,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.db import models
-from django.newforms.models import BaseModelForm, BaseInlineFormset
+from django.newforms.models import BaseModelForm, BaseModelFormSet
from django.contrib.admin.options import flatten_fieldsets, BaseModelAdmin
from django.contrib.admin.options import HORIZONTAL, VERTICAL
@@ -129,9 +129,9 @@ def _validate_inline(cls):
% (cls.__name__, attr))
# formset
- if hasattr(cls, 'formset') and not issubclass(cls.formset, BaseInlineFormset):
+ if hasattr(cls, 'formset') and not issubclass(cls.formset, BaseModelFormSet):
raise ImproperlyConfigured("`%s.formset` does not inherit from "
- "BaseInlineFormset." % cls.__name__)
+ "BaseModelFormSet." % cls.__name__)
def _validate_base(cls, model):
opts = model._meta
13 tests/regressiontests/modeladmin/models.py
View
@@ -797,6 +797,8 @@ class and an AdminSite instance, so let's just go ahead and do that manually
# formset
+>>> from django.newforms.models import BaseModelFormSet
+
>>> class FakeFormSet(object):
... pass
>>> class ValidationTestInline(TabularInline):
@@ -807,7 +809,16 @@ class and an AdminSite instance, so let's just go ahead and do that manually
>>> validate(ValidationTestModelAdmin, ValidationTestModel)
Traceback (most recent call last):
...
-ImproperlyConfigured: `ValidationTestInline.formset` does not inherit from BaseInlineFormset.
+ImproperlyConfigured: `ValidationTestInline.formset` does not inherit from BaseModelFormSet.
+
+>>> class RealModelFormSet(BaseModelFormSet):
+... pass
+>>> class ValidationTestInline(TabularInline):
+... model = ValidationTestInlineModel
+... formset = RealModelFormSet
+>>> class ValidationTestModelAdmin(ModelAdmin):
+... inlines = [ValidationTestInline]
+>>> validate(ValidationTestModelAdmin, ValidationTestModel)
"""
}
Please sign in to comment.
Something went wrong with that request. Please try again.