Python django.forms.models 模块,BaseModelFormSet() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用django.forms.models.BaseModelFormSet()

项目:byro    作者:byro    | 项目源码 | 文件源码
def formset_class(self):
        formset_class = inlineformset_factory(
            RealTransaction, VirtualTransaction, form=VirtualTransactionForm,
            formset=BaseModelFormSet, can_delete=True, extra=0,
        )
        return formset_class
项目:pretalx    作者:pretalx    | 项目源码 | 文件源码
def formset(self):
        formset_class = inlineformset_factory(
            Submission, Resource, form=ResourceForm, formset=BaseModelFormSet,
            can_delete=True, extra=0,
        )
        obj = self.get_object()
        return formset_class(
            self.request.POST if self.request.method == 'POST' else None,
            files=self.request.FILES if self.request.method == 'POST' else None,
            queryset=obj.resources.all() if obj else Resource.objects.none(),
            prefix='resource',
        )
项目:tissuelab    作者:VirtualPlants    | 项目源码 | 文件源码
def validate_formset(self, cls, model):
        " Validate formset is a subclass of BaseModelFormSet. "
        if hasattr(cls, 'formset') and not issubclass(cls.formset, BaseModelFormSet):
            raise ImproperlyConfigured("'%s.formset' does not inherit from "
                    "BaseModelFormSet." % cls.__name__)