I attached a patch to #8160 that fixes this issue (and probably #8071).

I'm not sure what parts of BaseModelFormSet are considered official
API. In the patch ModelForm.save() is now called by
ModelFormSet.save(), and I think the methods save_new, save_existing,
save_existing_objects, and save_new_objects are no longer needed. I
don't think get_queryset is needed either.

I know it's a rough patch, so any advice on how to improve it, or what
tests to add?

-Justin

ps. The *_factory methods seem odd to me. I wonder why metaclasses
weren't used here, but I understand that it's to close to 1.0 change
anything.

On Sun, Aug 17, 2008 at 7:57 PM, Justin Fagnani
<[EMAIL PROTECTED]> wrote:
> I just noticed that BaseModelFormSet takes a queryset and populates
> its forms initial data from the queryset, but doesn't set its forms
> instance attributes. Was this does by design?
>
> If not, it seem like the bottleneck is that BaseModelFormSet is
> completely relying on BaseFormSet to construct the forms, which
> obviously doesn't know about ModelForms and instances, but if
> BaseModelFormSet overrides _construct_form() is can set the instance.
> I worked around it by subclassing BaseModelFormSet:
>
> class InstanceFormSet(BaseModelFormSet):
>    def _construct_form(self, i, **kwargs):
>        if i < self._initial_form_count:
>            defaults = {'instance': self.queryset[i]}
>        else:
>            defaults = {}
>        defaults.update(kwargs)
>        return super(BaseModelFormSet, self)._construct_form(i, **defaults)
>
> but this is how I would have expected BaseModelFormSet to behave.
> Should I open a ticket?
>
> -Justin
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to