mirror of
https://github.com/django/django.git
synced 2025-07-04 01:39:20 +00:00
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
This commit is contained in:
parent
dce7cfee16
commit
81b185319c
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db import models
|
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 flatten_fieldsets, BaseModelAdmin
|
||||||
from django.contrib.admin.options import HORIZONTAL, VERTICAL
|
from django.contrib.admin.options import HORIZONTAL, VERTICAL
|
||||||
|
|
||||||
@ -129,9 +129,9 @@ def _validate_inline(cls):
|
|||||||
% (cls.__name__, attr))
|
% (cls.__name__, attr))
|
||||||
|
|
||||||
# formset
|
# 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 "
|
raise ImproperlyConfigured("`%s.formset` does not inherit from "
|
||||||
"BaseInlineFormset." % cls.__name__)
|
"BaseModelFormSet." % cls.__name__)
|
||||||
|
|
||||||
def _validate_base(cls, model):
|
def _validate_base(cls, model):
|
||||||
opts = model._meta
|
opts = model._meta
|
||||||
|
@ -797,6 +797,8 @@ ImproperlyConfigured: `ValidationTestInline.max_num` should be a integer.
|
|||||||
|
|
||||||
# formset
|
# formset
|
||||||
|
|
||||||
|
>>> from django.newforms.models import BaseModelFormSet
|
||||||
|
|
||||||
>>> class FakeFormSet(object):
|
>>> class FakeFormSet(object):
|
||||||
... pass
|
... pass
|
||||||
>>> class ValidationTestInline(TabularInline):
|
>>> class ValidationTestInline(TabularInline):
|
||||||
@ -807,7 +809,16 @@ ImproperlyConfigured: `ValidationTestInline.max_num` should be a integer.
|
|||||||
>>> validate(ValidationTestModelAdmin, ValidationTestModel)
|
>>> validate(ValidationTestModelAdmin, ValidationTestModel)
|
||||||
Traceback (most recent call last):
|
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)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user