[Django] #33447: min_num on formsets should not just be added to extra, again

4 views
Skip to first unread message

Django

unread,
Jan 18, 2022, 1:07:32 PMJan 18
to django-...@googlegroups.com
#33447: min_num on formsets should not just be added to extra, again
-------------------------------------+-------------------------------------
Reporter: typonaut | Owner: nobody
Type: New | Status: new
feature |
Component: Forms | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: | inlineformset_factory min_num extra
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
I have read #22628 and #27679.

I can see that the documentation says that if you have `min_num = 1` and
`extra = 1` then you will get two blank inline forms in a new form.

I am flagging this as a new feature, although I think it is really a bug.

When using `forms.models.inlineformset_factory` `min_num` and `extra`
input parameters are available. Logically `min_num` is really a validation
parameter where `extra` is a utility/UI parameter. I believe that given
this logic, with a new form and `min_num = 1` and `extra = 1` then there
should only be one inline form displayed, rather than two as currently
happens.

I would propose to add an additional input parameter to control this
bahaviour and account for any backward compatibility issues:
`min_num_minimise` as a boolean.

{{{
forms.models.inlineformset_factory(…
extra=1,
min_num=1,
min_num_minimise=True
)
}}}

This would render one inline form on a new form, where:

{{{
forms.models.inlineformset_factory(…
extra=1,
min_num=1,
min_num_minimise=False,
)
}}}

Would maintain the current behaviour – with the default being
`min_num_minimise=False`.

I believe that the current implementation is more than a little confusing
from a UI perspective. While it is possible to code around this
implementation and test for at least `min_num` forms, that is quite a lot
of work and more prone to break with updates.

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

Django

unread,
Jan 18, 2022, 1:19:17 PMJan 18
to django-...@googlegroups.com
#33447: min_num on formsets should not just be added to extra, again
-------------------------------------+-------------------------------------
Reporter: typonaut | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
inlineformset_factory min_num | Unreviewed
extra |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Description changed by typonaut:

Old description:

New description:

In addition, there is a bug in behaviour: if `min_num` is greater than
zero, a form action that deletes all existing inline forms is valid, which
should not be the case.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33447#comment:1>

Django

unread,
Jan 19, 2022, 10:29:00 AMJan 19
to django-...@googlegroups.com
#33447: min_num on formsets should not just be added to extra, again
-------------------------------------+-------------------------------------
Reporter: typonaut | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: 3.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
inlineformset_factory min_num | Unreviewed
extra |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => wontfix


Comment:

Hi.

I'm going to have to say wontfix here: Given the discussion on #27679 (and
the linked PR) it needs a consensus for change.

No arguments for the breaking were put forward in the four or so years
#27679 was left open, and I can't see there being an appetite for
introducing the single use kwarg here.
Nonetheless, if you want to write up the proposal (with links to the
relevant history) for the DevelopersMailingList, you can do that to see.

Thanks.

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

Reply all
Reply to author
Forward
0 new messages