Open typonaut opened 1 year ago
from extra_views import FormSetView
Hi. The above can be used to render a single formset which is not connected to a model. Inline formsets only exist for models, as it is the parent model which links the child formsets together.
There isn't a class in this library to do what you've asked.
In order to create a generic view which just has a single form and a few different formsets, create a subclass of django.views.generic.edit.FormView
which has all the same methods as ProcessFormWithInlinesView and ModelFormWithInlinesMixin, with all references to models removed.
Formsets would be represented using BaseFormSetFactory instances. If access to the request object was needed, you'd need to do something like InlineFormSetFactory.
Thanks. Would a class, as my request, be useful in Extra Views, or is it a little too niche?
In my opinion, it probably is too niche. The objective of this package is to replicate the functionality of the Django Admin in generic views and it is outside of that. I also think the formsetfactory constructor classes like BaseFormSetFactory
and InlineFormSetFactory
aren't intuitive to new users and adding more would make the package less comprehensible.
From my personal experience in writing django apps, this has only come up once and it's just simpler to write either a one-off CBV or even a functional view to handle multiple formsets.
Which view should one use if one wants to create forms/formsets that are not attached to models, ie something like
CreateWithInlinesView
with associatedInlineFormsetFactory
where there are no models?Or, a technique for managing such?
Thanks