--
Ticket URL: <https://code.djangoproject.com/ticket/18830>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
* resolution: => fixed
* stage: Unreviewed => Accepted
Comment:
I'm going to mark this as accepted, but with a slightly broader scope than
you've given the problem.
This problem exists for form wizards, but it also exists for generic
views, too. The root of the problem is that you need to be able to combine
forms and formsets (or multiple forms and formsets) on a single page. This
is true of a page of a wizard, but it's also true of a "FormView" as well.
Now - the nice thing is that Forms and Formsets share a common interface
-- that's why you're able to use a formset as a page in a wizard. To my
mind, what we need to do here is write a container object that can wrap
multiple forms and formsets,
I've done this on some of my own projects, and the approach works fine;
I've attached an example of the code you can use to do it. This needs a
lot of work to turn it into a feature, but I think it's a feature worth
adding.
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:1>
* status: closed => reopened
* resolution: fixed =>
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:2>
* cc: hv@… (added)
Comment:
I like the idea of a FormContainer very much.
A FormContainer should be able to contain: Forms, FormFields and
FormContainers.
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:3>
Comment (by anonymous):
Is this now a upcoming feature?
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:5>
* cc: thepapermen (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:6>
* cc: bouke (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:7>
* cc: dokterbob (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:8>
Comment (by benoitbryon):
Could Form, FormSet and FormWizard inherit from some base class (Form or
BaseForm)?
If they all inherit from a base class, FormView could support them all!
Note: I don't know if is covered by another ticket.
Also, there is a project that aims to make one form out of several:
https://pypi.python.org/pypi/django-composite-form/
How do views handle forms?
* they use the __init__(), is_valid() and save() methods
* templates iterate over sets of fields, iterate over fields, or call
__unicode__()
* isn't it enough?
I mean, from views "point of view", forms, formsets and "composite forms"
are really similar.
Wizards may be a bit different.
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:9>
Comment (by anonymous):
why not allow forms to contain other forms out of the box, like in
WTForms?
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:10>
* owner: nobody => inglesp
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:11>
Comment (by Anthony King):
Is this still something people want?
I'm investigating doing something along these lines at work, to move away
from an inflexible solution conceived under time constraints.
the WTForm pattern looks like the easiest pattern to implement as a
library, though it will probably cause issues with third-party form
renderers, such as django-bootstrap3.
I'll see how far this can be taken using Form wrappers, working in a
similar fashion to how a MutliValueField works.
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:11>
Comment (by Thomas Güttler):
Replying to [comment:11 Anthony King]:
> Is this still something people want?
>
> I'm investigating doing something along these lines at work, to move
away from an inflexible solution conceived under time constraints.
>
> the WTForm pattern looks like the easiest pattern to implement as a
library, though it will probably cause issues with third-party form
renderers, such as django-bootstrap3.
>
>
> I'll see how far this can be taken using Form wrappers, working in a
similar fashion to how a MutliValueField works.
Yes, I want something like this. In particular I am missing a container
for N django forms.
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:12>
* status: new => closed
* resolution: => wontfix
* stage: Accepted => Unreviewed
Comment:
The idea behind this feature is quite fuzzy. It sounds like a third-party
package is the best way to proceed as it doesn't need to be included in
Django itself.
--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:13>