On Thu, 2009-09-17 at 03:58 -0700, mag wrote:
> Hello,
> 
> I'm novice in Django and I' would like to create an edition formset to
> edit questions, for example. I' already have a formset to add
> question:
> 
> My add formset :
> 
> def manage_polls(request):
>     PollFormSet = formset_factory(PollForm, extra=2)
>     if request.method == 'POST':
>         formset = PollFormSet(request.POST)
>         if formset.is_valid():
>             for form in fromset:
>                 form.save()
> 
>     else:
>         formset = PollFormSet()
>     return render_to_response('manage_polls.html', {'formset':
> formset})
> 
> 
> 
> To edit all questions (I've already created) with a formset, I'need to
> give an instance, but how  can I' do it ?
> 
> 
> Thank you
> 
> Magali
> 
PollForm doesn't seem to be a model form? If you were using a ModelForm
(and hence modelformset_factory) you would pass a 'queryset' argument to
the formset. See
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#changing-the-queryset

Regular FormSets take an 'initial' argument, which is a list of
dictionaries. See 
http://docs.djangoproject.com/en/dev/topics/forms/formsets/#using-initial-data-with-a-formset

Cheers

Tom


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

  • Formset mag
    • Re: Formset Tom Evans

Reply via email to