Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored July 17, 2008
6  django/contrib/admin/validation.py
... ...
@@ -1,7 +1,7 @@
1 1
 
2 2
 from django.core.exceptions import ImproperlyConfigured
3 3
 from django.db import models
4  
-from django.newforms.models import BaseModelForm, BaseInlineFormset
  4
+from django.newforms.models import BaseModelForm, BaseModelFormSet
5 5
 from django.contrib.admin.options import flatten_fieldsets, BaseModelAdmin
6 6
 from django.contrib.admin.options import HORIZONTAL, VERTICAL
7 7
 
@@ -129,9 +129,9 @@ def _validate_inline(cls):
129 129
                     % (cls.__name__, attr))
130 130
 
131 131
     # formset
132  
-    if hasattr(cls, 'formset') and not issubclass(cls.formset, BaseInlineFormset):
  132
+    if hasattr(cls, 'formset') and not issubclass(cls.formset, BaseModelFormSet):
133 133
         raise ImproperlyConfigured("`%s.formset` does not inherit from "
134  
-                "BaseInlineFormset." % cls.__name__)
  134
+                "BaseModelFormSet." % cls.__name__)
135 135
 
136 136
 def _validate_base(cls, model):
137 137
     opts = model._meta
13  tests/regressiontests/modeladmin/models.py
@@ -797,6 +797,8 @@ class and an AdminSite instance, so let's just go ahead and do that manually
797 797
 
798 798
 # formset
799 799
 
  800
+>>> from django.newforms.models import BaseModelFormSet
  801
+
800 802
 >>> class FakeFormSet(object):
801 803
 ...     pass
802 804
 >>> class ValidationTestInline(TabularInline):
@@ -807,7 +809,16 @@ class and an AdminSite instance, so let's just go ahead and do that manually
807 809
 >>> validate(ValidationTestModelAdmin, ValidationTestModel)
808 810
 Traceback (most recent call last):
809 811
 ...
810  
-ImproperlyConfigured: `ValidationTestInline.formset` does not inherit from BaseInlineFormset.
  812
+ImproperlyConfigured: `ValidationTestInline.formset` does not inherit from BaseModelFormSet.
  813
+
  814
+>>> class RealModelFormSet(BaseModelFormSet):
  815
+...     pass
  816
+>>> class ValidationTestInline(TabularInline):
  817
+...     model = ValidationTestInlineModel
  818
+...     formset = RealModelFormSet
  819
+>>> class ValidationTestModelAdmin(ModelAdmin):
  820
+...     inlines = [ValidationTestInline]
  821
+>>> validate(ValidationTestModelAdmin, ValidationTestModel)
811 822
 
812 823
 """
813 824
 }

0 notes on commit 81b1853

Please sign in to comment.
Something went wrong with that request. Please try again.