#8160: ModelFormset ignores form properties
------------------------------------------------+---------------------------
Reporter: [EMAIL PROTECTED] | Owner: nobody
Status: new | Milestone: 1.0
Component: Forms | Version: SVN
Resolution: | Keywords: formset
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
------------------------------------------------+---------------------------
Changes (by justinf):
* cc: [EMAIL PROTECTED] (added)
* has_patch: 0 => 1
* needs_tests: 0 => 1
Comment:
I attached a rough initial patch that fixes both issues in this ticket.
{{{modelform_factory()}}} is changed so that the form argument's
{{{Meta}}} is used to construct the model form. if 'fields' or 'exclude'
are passed in, they override {{{Meta}}}. This fixes the first issue for
both {{{modelformset_factory}}} and {{{inlineformset_factory}}}.
To get {{{save()}}} called on the forms, I rewrote
{{{BaseModelFormSet.save()}}} to call it's {{{forms.save()}}}. I got rid
of save_existing_objects() and save_new_objects(), but I'm not sure if
those are considered part of the public API. {{{BaseModelFormSet}}} also
now overrides {{{_construct_form()}}} in order to set the instance
attribute of the forms. This also care makes the forms in a model formset
behave more like normal model forms.
There's one nasty hack where a {{QuerySet}} is passed as the 'initial'
argument for {{BaseFormSet.__init__()}} so that {{{_initial_form_count}}}
and {{{_total_form_count}}} are set properly. Fixing that will probably
require changes to {{BaseFormSet}}.
I think this patch fixes #8071 also.
--
Ticket URL: <http://code.djangoproject.com/ticket/8160#comment:3>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---