I figured it out.  The problem was that I forgot to include

{{ formset.management_form }}

in my template.

But now I have a new problem.  After validation, the post gets saved
but not the image.

On Sep 2, 5:08 pm, Aaron <[EMAIL PROTECTED]> wrote:
> Hi, has anyone encounter a similar error?
>
> ValidationError at /post/add/
> [u'ManagementForm data is missing or has been tampered with']
>
> I am able to display the inline form, but the error occurs when I try
> to pass the request.POST data into the PostImageFormSet
>
> Below is my view:
> -----------------------------------------------------------------------------------------------------------------------
> def add_post(request):
>
>     section_id = int(request.GET.get('s', 0))
>     category_id = int(request.GET.get('c', 0))
>
>     PostImageFormSet = \
>         inlineformset_factory(Post, PostImage, max_num=1)
>
>     if request.method == 'POST':
>         form = PostForm(data=request.POST)
>         formset = PostImageFormSet(data=request.POST)
>         if form.is_valid() and formset.is_valid():
>             new_post = form.save(commit=False)
>             new_post.poster = request.user
>             new_post.save()
>             formset.instance = new_post
>             formset.save()
>             return HttpResponseRedirect(new_post.get_absolute_url())
>     else:
>         form = PostForm()
>         formset = PostImageFormSet()
>
>     return render_to_response('classified/post_form.html',
>                               { 'form': form,
>                                 'formset': formset,
>                                 'add': True,
>                                 'section_id': section_id,
>                                 'category_id': category_id,
>                                 'categories':
> Category.objects.all() },
>
> context_instance=RequestContext(request))
>
> -----------------------------------------------------------------------------------------------------------------------
>
> Any helpful info regarding this error will be greatly appreciated.
>
> Aaron
--~--~---------~--~----~------------~-------~--~----~
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