--
Ticket URL: <https://code.djangoproject.com/ticket/29956>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:1>
* owner: nobody => Hasan Ramezani
* status: new => assigned
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:2>
Comment (by Hasan Ramezani):
Here is the summary of conversation between me and @claudep on the
[https://github.com/django/django/pull/10660#issuecomment-440327124 PR] :
I did this feature by adding the `order_field_widget` to `formset_factory`
functions. (now available in the PR)
@claudep suggested managing this by adding a key in `widgets` property of
`ModelForm`. something like this:
{{{
class AuthorForm(ModelForm):
class Meta:
model = Author
fields = ('name', 'title', 'birth_date')
widgets = {
'ORDER': HiddenInput(),
}
}}}
It works for `ModelForm` because we can access the `widgets` property of
ModelForm by : `model_form._meta.widgets`.
But it is possible to have this feature for `formset` which generated by
the normal forms, because the normal form that inherits from `forms.Form`
has not the `widgets` property.
So @claudep suggest to first add this feature just for ModelForm.
what is the final decision?
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:3>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:4>
* needs_better_patch: 1 => 0
Comment:
I change my PR and manage the widget based on ORDER key in widgets
dictionary. and this feature just works for ModelForm now.
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:5>
* needs_better_patch: 0 => 1
* version: 2.1 => master
Comment:
On the PR I've suggested a third-option (rather than adding an argument to
`formset_factory()` or using the ModelForm's `Meta.widgets` ) to have
users subclass `BaseFormSet` in this case and pass that as the `formset`
argument to `formset_factory()`.
This keeps the logic in with the formsets but does not expand the
signature of `formset_factory()`, which is already long enough.
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:6>
* needs_better_patch: 1 => 0
Comment:
I changed the PR based on your suggestion. please check it and let me know
if something else is required.
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:7>
* needs_better_patch: 0 => 1
Comment:
Small tweaks needed then good to go I think.
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:8>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:9>
Comment (by Hasan Ramezani):
Requested changes are Done.
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:10>
* needs_docs: 0 => 1
Comment:
As per PR, the docs here just need a small amount of work and then this is
looking good to go.
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:11>
* needs_docs: 1 => 0
Comment:
Docs fixed as your request.
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:12>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"5fc5d935120a5d9d428b969ad209695704c10c73" 5fc5d935]:
{{{
#!CommitTicketReference repository=""
revision="5fc5d935120a5d9d428b969ad209695704c10c73"
Fixed #29956 -- Allowed overriding an order field widget in formsets.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29956#comment:13>