[Django] #18830: FormWizard with Formset and Form Fields mixed on same page

27 views
Skip to first unread message

Django

unread,
Aug 21, 2012, 11:08:20 PM8/21/12
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+--------------------
Reporter: jeff@… | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------
I would like to request something like the following:
On a given page in a FormWizard, support the ability to mix a formset
along with other form fields.

A use-case would be a page in a wizard that lets you add N users to email,
and a textarea to customize this email.

The code for such a thing would look like

forms.py
{{{
# Step 1 in wizard
class Step1Form(forms.Form):
# interesting form fields...

# Form for the email addresses used in Step 2 Formset
class EmailAddressForm(forms.Form):
email = forms.EmailField()

# Step 2 in wizard
class EmailAddressesAndText(forms.Form):
emailText = forms.Textarea()
emailAddressFormSet = formset_factory(EmailAddressForm,
can_delete=True, ...)
}}}

in urls.py
{{{
##
named_formwizard_forms = (
('Step1', Step1Form),
('Step2', EmailAddressesAndText),
)
}}}

This would be a very clean way to mix form fields and an embedded formset
in a way that can be leveraged as part of the FormWizard found in 1.4

Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/18830>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 22, 2012, 6:07:27 AM11/22/12
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------
Reporter: jeff@… | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: 1.4
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by russellm):

* 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>

Django

unread,
Nov 22, 2012, 8:17:23 AM11/22/12
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------
Reporter: jeff@… | Owner: nobody
Type: New feature | Status: reopened
Component: Forms | Version: 1.4
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by russellm):

* status: closed => reopened
* resolution: fixed =>


--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:2>

Django

unread,
Feb 14, 2013, 9:52:04 AM2/14/13
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------
Reporter: jeff@… | Owner: nobody
Type: New feature | Status: reopened
Component: Forms | Version: 1.4

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by guettli):

* 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>

Django

unread,
Mar 29, 2013, 11:27:39 PM3/29/13
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------

Reporter: jeff@… | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by anonymous):

Is this now a upcoming feature?

--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:5>

Django

unread,
Apr 22, 2013, 3:12:11 PM4/22/13
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------

Reporter: jeff@… | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by thepapermen):

* cc: thepapermen (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:6>

Django

unread,
Apr 25, 2013, 4:17:56 AM4/25/13
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------

Reporter: jeff@… | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by bouke):

* cc: bouke (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:7>

Django

unread,
May 17, 2013, 4:49:28 AM5/17/13
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------

Reporter: jeff@… | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by dokterbob):

* cc: dokterbob (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:8>

Django

unread,
May 17, 2013, 5:01:30 AM5/17/13
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------

Reporter: jeff@… | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

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>

Django

unread,
Aug 7, 2014, 1:22:27 AM8/7/14
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------

Reporter: jeff@… | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

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>

Django

unread,
Mar 5, 2015, 2:35:37 PM3/5/15
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------
Reporter: jeff@… | Owner: inglesp
Type: New feature | Status: assigned
Component: Forms | Version: 1.4

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by inglesp):

* owner: nobody => inglesp
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/18830#comment:11>

Django

unread,
Aug 22, 2017, 8:04:46 AM8/22/17
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------

Reporter: jeff@… | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

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.

Django

unread,
Aug 22, 2017, 8:43:54 AM8/22/17
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+------------------------------------

Reporter: jeff@… | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

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>

Django

unread,
Jul 31, 2023, 5:20:55 AM7/31/23
to django-...@googlegroups.com
#18830: FormWizard with Formset and Form Fields mixed on same page
-----------------------------+--------------------------------------
Reporter: jeff@… | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: 1.4
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* 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>

Reply all
Reply to author
Forward
0 new messages