def get_formset(self):
     """
     Returns the formset class from the inline formset factory
     """
     # Implementation detail:
     # Since `polymorphic_modelformset_factory` and `polymorphic_inlineformset_factory` mainly
     # reuse the standard factories, and then add `child_forms`, the same can be done here.
     # This makes sure the base class construction is completely honored.
     FormSet = super(PolymorphicFormSetMixin, self).get_formset()
     FormSet.child_forms = polymorphic_child_forms_factory(self.get_formset_children(), **self.get_formset_child_kwargs())
     return FormSet
예제 #2
0
 def get_formset(self):
     """
     Returns the formset class from the inline formset factory
     """
     # Implementation detail:
     # Since `polymorphic_modelformset_factory` and `polymorphic_inlineformset_factory` mainly
     # reuse the standard factories, and then add `child_forms`, the same can be done here.
     # This makes sure the base class construction is completely honored.
     FormSet = super(PolymorphicFormSetMixin, self).get_formset()
     FormSet.child_forms = polymorphic_child_forms_factory(
         self.get_formset_children(), **self.get_formset_child_kwargs())
     return FormSet
예제 #3
0
    def get_formset(self, request, obj=None, **kwargs):
        """
        Construct the generic inline formset class.
        """
        # Construct the FormSet class. This is almost the same as parent version,
        # except that a different super is called so generic_inlineformset_factory() is used.
        # NOTE that generic_inlineformset_factory() also makes sure the GFK fields are excluded in the form.
        FormSet = GenericInlineModelAdmin.get_formset(self, request, obj=obj, **kwargs)

        FormSet.child_forms = polymorphic_child_forms_factory(
            formset_children=self.get_formset_children(request, obj=obj)
        )
        return FormSet
예제 #4
0
    def get_formset(self, request, obj=None, **kwargs):
        """
        Construct the generic inline formset class.
        """
        # Construct the FormSet class. This is almost the same as parent version,
        # except that a different super is called so generic_inlineformset_factory() is used.
        # NOTE that generic_inlineformset_factory() also makes sure the GFK fields are excluded in the form.
        FormSet = GenericInlineModelAdmin.get_formset(self, request, obj=obj, **kwargs)

        FormSet.child_forms = polymorphic_child_forms_factory(
            formset_children=self.get_formset_children(request, obj=obj)
        )
        return FormSet
예제 #5
0
    def get_formset(self, request, obj=None, **kwargs):
        """
        Construct the inline formset class.

        This passes all class attributes to the formset.

        :rtype: type
        """
        # Construct the FormSet class
        FormSet = super().get_formset(request, obj=obj, **kwargs)

        # Instead of completely redefining super().get_formset(), we use
        # the regular inlineformset_factory(), and amend that with our extra bits.
        # This code line is the essence of what polymorphic_inlineformset_factory() does.
        FormSet.child_forms = polymorphic_child_forms_factory(
            formset_children=self.get_formset_children(request, obj=obj))
        return FormSet
예제 #6
0
    def get_formset(self, request, obj=None, **kwargs):
        """
        Construct the inline formset class.

        This passes all class attributes to the formset.

        :rtype: type
        """
        # Construct the FormSet class
        FormSet = super(PolymorphicInlineModelAdmin, self).get_formset(request, obj=obj, **kwargs)

        # Instead of completely redefining super().get_formset(), we use
        # the regular inlineformset_factory(), and amend that with our extra bits.
        # This code line is the essence of what polymorphic_inlineformset_factory() does.
        FormSet.child_forms = polymorphic_child_forms_factory(
            formset_children=self.get_formset_children(request, obj=obj)
        )
        return FormSet