--
Ticket URL: <https://code.djangoproject.com/ticket/18166>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Hmm, wiki markup that turns !__init!__ into __init__ is less than useful
for Python discussion :/
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:1>
* needs_docs: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:2>
--
Comment (by lrekucki):
Replying to [comment:1 tevans]:
> Hmm, wiki markup that turns !__init!__ into __init__ is less than useful
for Python discussion :/
You can use formatting: !{{{ __init__ }}} will show as {{{__init__}}}.
There's both live preview and a preview button.
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:3>
Comment (by akaariai):
Just as an idea: how about defining a new method:
{{{
def get_single_form(self, i, defaults):
"""
Override me to have total control over the single forms.
"""
return self.form(**defaults)
}}}
and use that instead of self.form() in the _construct_form() method. This
would be more powerful and easier to implement.
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:4>
Comment (by tevans):
Replying to [comment:4 akaariai]:
> Just as an idea: how about defining a new method:
> {{{
> def get_single_form(self, i, defaults):
> """
> Override me to have total control over the single forms.
> """
> return self.form(**defaults)
> }}}
> and use that instead of self.form() in the _construct_form() method.
This would be more powerful and easier to implement.
Yes, I like that. I would like to also keep the idea of being able to
contribute to a form's kwargs without defining a {{{BaseFormSet}}}
subclass, eg by passing them to {{{BaseFormSet.__init__}}}.
I should get some time this w/e to re-roll the patch.
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:5>
* needs_better_patch: 0 => 1
* stage: Unreviewed => Accepted
Comment:
Agreed, a method for implementing this is a good idea, but please let's
skip the redundant 'simple' prefix, just call it `get_form`.
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:6>
Comment (by jezdez):
Oops that was me.
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:7>
* owner: nobody => sergei-maertens
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:8>
Comment (by sergei-maertens):
I'll have a go at this
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:9>
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:10>
Comment (by Russell Keith-Magee <russell@…>):
In [changeset:"fe21fb810a1bd12b10c534923809423b5c1cf4d7" fe21fb81]:
{{{
#!CommitTicketReference repository=""
revision="fe21fb810a1bd12b10c534923809423b5c1cf4d7"
Merge pull request #4757 from sergei-maertens/ticket_18166
Fixed #18166 -- Added ability to pass kwargs to the form constructor in a
formset.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:12>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"238e2ac3690755d0e6c2dfca815e2b6f84a47f6e" 238e2ac3]:
{{{
#!CommitTicketReference repository=""
revision="238e2ac3690755d0e6c2dfca815e2b6f84a47f6e"
Fixed #18166 -- Added form_kwargs support to formsets.
By specifying form_kwargs when instantiating the formset, or overriding
the `get_form_kwargs` method on a formset class, you can pass extra
keyword arguments to the underlying `Form` instances.
Includes tests and documentation update.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/18166#comment:11>