On 20 nov, 05:33, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 9:14 PM, [EMAIL PROTECTED]
>
>
>
> <[EMAIL PROTECTED]> wrote:
>
> > On 20 nov, 05:01, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> >> On Wed, Nov 19, 2008 at 8:59 PM, Brian Rosner <[EMAIL PROTECTED]> wrote:
> >> > On Wed, Nov 19, 2008 at 8:43 PM, Luper Rouch <[EMAIL PROTECTED]> wrote:
> >> >> For django to save the formset correctly when it is submitted, I have to
> >> >> manually set INITIAL_FORMS to 0 in javascript (because the objects are
> >> >> not really in the database).
>
> >> > It looks like you are trying to shove a square object through a round
> >> > hole. Why are you using a model formset when there is "real" queryset?
> >> > Model formsets are simply a thin layer over formsets. It sounds like
> >> > you need to those to cleanly write your code and not resort to hacking
> >> > a model formset to work without a real queryset.
>
> >> Ugh. That didn't read as well as I hoped :)
>
> >> I meant to ask, why are you using model formsets when there is no
> >> "real" queryset? You should just use formsets.
>
> > django/forms/models.py is 747 lines long, I would not call that a thin
> > layer :)
>
> That file is not just model formset code. In terms of what a model
> formset does, it is thin. It doesn't not change any behavior of a
> regular formset. Just provides the additional layer to hook up with
> models. I still consider that thin ;)
>
>
>
> > I use it because I want to write forms that save models, and avoid
> > duplicating my model structure in the form class. Is'nt it what
> > modelforms are meant for ?
>
> Then why are you not able to pass in a queryset? What data are you
> sending to the server to generate the formset? From the little
> explained code are they just primary keys?

[1, 2, 3] is just some example data, not primary keys (actually I'm
passing dictionaries, but I tried to keep the example code short). It
is used to populate the formset, which is then rendered, inserted in
the page via an AJAX call, and eventually submitted to another view to
save it to the database.

I use a fake queryset because it's the only way that I found to
populate the formset (using a real queryset would lead to the same
problem anyway), hence I wonder if there is a cleaner way to do what I
want without reinventing modelforms, or using separate form classes
for saving and creating my dynamic formsets.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to