Skip to content
Back to top
View this page
Edit this page

# extra_views

The `extra_views.formsets` provides a simple way to handle formsets. The `extra_views.advanced` provides a method to combine that with a create/update form.

This package provides classes that support both options for polymorphic formsets.

class polymorphic.contrib.extra_views.PolymorphicFormSetView

  Bases: `PolymorphicFormSetMixin`, `ModelFormSetView`

  A view that displays a single polymorphic formset.

      from polymorphic.formsets import PolymorphicFormSetChild

      class ItemsView(PolymorphicFormSetView):
          model = Item
          formset_children = [
              PolymorphicFormSetChild(ItemSubclass1),
              PolymorphicFormSetChild(ItemSubclass2),
          ]

  formset_class

    alias of `BasePolymorphicModelFormSet`

class polymorphic.contrib.extra_views.PolymorphicInlineFormSet

  Bases: `PolymorphicFormSetMixin`, `InlineFormSetFactory`

  An inline to add to the `inlines` of the `CreateWithInlinesView` and `UpdateWithInlinesView` class.

      from polymorphic.formsets import PolymorphicFormSetChild

      class ItemsInline(PolymorphicInlineFormSet):
          model = Item
          formset_children = [
              PolymorphicFormSetChild(ItemSubclass1),
              PolymorphicFormSetChild(ItemSubclass2),
          ]

      class OrderCreateView(CreateWithInlinesView):
          model = Order
          inlines = [ItemsInline]

          def get_success_url(self):
              return self.object.get_absolute_url()

  formset_class

    alias of `BasePolymorphicInlineFormSet`

class polymorphic.contrib.extra_views.PolymorphicInlineFormSetView

  Bases: `PolymorphicFormSetMixin`, `InlineFormSetView`

  A view that displays a single polymorphic formset - with one parent object. This is a variation of the `extra_views` package classes for django-polymorphic.

      from polymorphic.formsets import PolymorphicFormSetChild

      class OrderItemsView(PolymorphicInlineFormSetView):
          model = Order
          inline_model = Item
          formset_children = [
              PolymorphicFormSetChild(ItemSubclass1),
              PolymorphicFormSetChild(ItemSubclass2),
          ]

  formset_class

    alias of `BasePolymorphicInlineFormSet`