* cc: tgecho (added)
* ui_ux: => 0
* easy: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* easy: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:7>
* cc: kitsunde@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:8>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:9>
* stage: Design decision needed => Accepted
Comment:
#17642 has a patch to apply this feature to admin inlines.
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:10>
Comment (by wim@…):
Hi, probably it is a good idea to add min_num to modelformset_factory and
inlineformset_factory as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:11>
* owner: nobody => AnkitBagaria
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:12>
Comment (by tback):
Hi AnkitBagria, I just started working on this too. I'm in Utrecht right
now, I'm also in #django-sprint. My nick is tback.
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:13>
Comment (by tback):
I think I fixed it. https://github.com/django/django/pull/784
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:14>
Comment (by tback):
Sorry, it's not fixed yet. BaseModelFormsets are still broken. The current
state of my work is here: https://github.com/tback/django/tree/formset-
min-num
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:15>
* status: assigned => new
* owner: AnkitBagaria =>
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:16>
* status: new => assigned
* owner: => AnkitBagaria
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:17>
* status: assigned => new
* owner: AnkitBagaria =>
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:18>
* owner: => yokomizor
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:19>
Comment (by yokomizor):
Please, check it out: https://github.com/django/django/pull/1208
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:20>
* cc: timograham@… (added)
* needs_better_patch: 0 => 1
* needs_docs: 0 => 1
Comment:
Thanks, the patch no longer merges cleanly so it needs to be rebased. It
also needs documentation including a mention in the 1.7 release notes. If
you could add that, I will try to review and commit it.
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:21>
Comment (by mjtamlyn):
I'm pretty concerned about what the implementation for this looks like. It
seems to me that every formset on every Django site would now have to have
the extra "MIN" field. Whilst in theory this shouldn't break anyone's
sites, it will almost certainly break everyone's tests. I'd prefer a less
backwardsly problematic patch for a relatively minor feature.
That said, I think the feature is probably useful. Perhaps a patch could
be devised which means the "MAX" field is not required either?
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:22>
* cc: me@… (added)
Comment:
Patch rebased.
Could someone please review?
https://github.com/django/django/pull/1444
About backward problematic, I don't know how can I do that. Any
suggestions?
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:23>
* needs_docs: 1 => 0
Comment:
I left comments on the pull request. I'm not sure there's actually any
backwards compatibility concerns as the parameters aren't actually
required in POST data as far as I can tell.
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:24>
Comment (by yokomizor):
Thanks timo!
I adjust the pull request based on your comments.
I rebased it. The old commit with comments can be seen at
https://github.com/yokomizor/django/commit/35d40939f89990c01f4c31ac10a29e3ec809d26e.
Could someone please review?
https://github.com/django/django/pull/1444
About the backward problematic, maybe the only backwards compatibility
concerns are in tests that test formset.as_X() return.
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:25>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"df27803a55ffea71d468a6aab0d897caa2b7a797"]:
{{{
#!CommitTicketReference repository=""
revision="df27803a55ffea71d468a6aab0d897caa2b7a797"
Fixed #9532 -- Added min_num and validate_min on formsets.
Thanks gsf for the suggestion.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:26>
Comment (by timo):
It would also be useful to add this to `modelformset_factory`,
`inlineformset_factory`, etc. Ticket #17642 is open for that issue -- it
has a patch and the branch from tback above also looks relevant.
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:27>
* cc: tchristiansen (added)
Comment:
Why is min_num added to extra?
This makes no sense to me, and makes extra useless in combination with
min_num.
extra=3 and min_num=3 resulting 6 forms, which is absolutely not what I
would expect (3 forms).
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:28>
Comment (by yokomizor):
I think this is there because when you set min_num as 3 you want at least
3 extra forms.
Maybe we should remove it, or just clarify in the docs.
What about set extra equals to min_num when min_num is greater than extra?
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:29>
Comment (by timo):
I agree a documentation improvement would be welcome.
@tchristiansen, is there a case you foresee where min_num=X and you
wouldn't want at least X extra forms?
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:30>
Comment (by melinath):
@timo I would set min_num=3 if there should be at least three things. I
would set extra=3 if I wanted three blank forms presented.
The implementation here means that there will *always* be '''six''' blank
forms - existing objects are *not* taken into account.
To put it another way, if min_num is 3, and extra is 2, and there are
already 2 existing objects, I would expect to have either 4 forms (2 extra
on top of existing objects) or 5 forms (2 extra on top of the minimum.)
With the code as it is, I will instead get '''seven forms''' - two for the
existing objects, and an additional seven from extra.
Ran into this behavior while working on #17642. Possible this is only a
modelformset issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:31>
Comment (by timo):
I agree existing objects should be taken into account so the number of
blank forms should be (min_num + extra - existing objects). Let's call it
a bug and fix it now.
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:32>
Comment (by melinath):
Opened a new ticket for this: #22628
--
Ticket URL: <https://code.djangoproject.com/ticket/9532#comment:33>