However, the kwarg can't be required, because of the empty_form property,
which doesn't have any way of marshall extra kwargs to the form (though it
can add fields), as such, the empty_form definition must be copy-pasted
entirely, which isn't ideal if the definition upstream (ie: in Django)
shifts over time.
A private api method:
{{{
def _get_empty_form_kwargs(self):
return {}
}}}
which could be dictionary expanded into the empty_form would allow for
passing required arguments in [I believe] a backwards compatible way,
while allowing userland code to replace less of the core FormSet
functionality.
The final empty_form might be something like:
{{{
@property
def empty_form(self):
form = self.form(
auto_id=self.auto_id,
prefix=self.add_prefix('__prefix__'),
empty_permitted=True,
**self._get_empty_form_kwargs(),
)
self.add_fields(form, None)
return form
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21501>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/21501#comment:1>
* status: new => closed
* cc: berker.peksag@… (added)
* resolution: => duplicate
Comment:
This looks like a duplicate of #18166. A new `get_form_kwargs` method has
been added in 238e2ac3690755d0e6c2dfca815e2b6f84a47f6e.
--
Ticket URL: <https://code.djangoproject.com/ticket/21501#comment:2>