Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View to use for non-model forms #255

Open
typonaut opened this issue Nov 18, 2022 · 3 comments
Open

View to use for non-model forms #255

typonaut opened this issue Nov 18, 2022 · 3 comments

Comments

@typonaut
Copy link

Which view should one use if one wants to create forms/formsets that are not attached to models, ie something like CreateWithInlinesView with associated InlineFormsetFactory where there are no models?

Or, a technique for managing such?

Thanks

@sdolemelipone
Copy link
Collaborator

sdolemelipone commented Nov 18, 2022

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.

@typonaut
Copy link
Author

Thanks. Would a class, as my request, be useful in Extra Views, or is it a little too niche?

@sdolemelipone
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants