Debian Codegraph @

src/polymorphic/tests/examples/integrations/extra_views/views.py

raw
1 from polymorphic.contrib.extra_views import PolymorphicFormSetView
2 from polymorphic.formsets import PolymorphicFormSetChild
3 from django.urls import reverse_lazy
4 from ..models import Article, BlogPost, NewsArticle
5
6
7 class ArticleFormSetView(PolymorphicFormSetView):
8 model = Article
9 template_name = "extra_views/article_formset.html"
10 success_url = reverse_lazy("extra_views:articles")
11 fields = "__all__"
12
13 # extra will add two empty forms for models in the order of their appearance
14 # in formset_children
15 factory_kwargs = {"extra": 2, "can_delete": True}
16
17 formset_children = [
18 PolymorphicFormSetChild(BlogPost, fields="__all__"),
19 PolymorphicFormSetChild(NewsArticle, fields="__all__"),
20 ]