On 20 nov, 06:01, "Brian Rosner" <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 19, 2008 at 9:53 PM, [EMAIL PROTECTED]
>
> <[EMAIL PROTECTED]> wrote:
>
> > 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.
>
> I think from what I gather you are looking to create an "add"-only
> model formset? If so take a look athttp://code.djangoproject.com/ticket/9538.
> I have written some
> information on that ticket that may be of use to you.
>
Yes I tried the approach you're talking about in the ticket:
FormSet = modelformset_factory(SomeModel, extra=3)
This creates 3 blank forms with INITIAL_FORMS=0, which is fine. But
then how can I populate this formset with some initial data instead of
the model's default values ? As I said:
forms = FormSet(initial=[{"field": 1}, {"field": 2}, {"field": 3}])
Or even:
forms = FormSet(queryset=SomeModel.objects.none(), initial=[{"field":
1}, {"field": 2}, {"field": 3}])
Does not work.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---