This example code and example is based on the tutorial provided in your 
URL.  Formsets do not have a save_all() function by default.  The provided 
save_all() does not return back any object, so you should provide a 
success_url or override the function get_success_url() in your class.
You'll need to override the "form_valid()" method to call save_all(), 
rather than a simple save().  Here's a simple example:

class FormsetView(UpdateView):
    model = Block
    form_class = BuildingFormset
    def form_valid(self, form):
        self.object = form.save_all()
        return super(ModelFormMixin, self).form_valid(form)

Use the other code from the blog. self.object is used if you don't specify 
a success_url, it uses it like self.object.get_absolute_url() to determine 
the URL you go to once the form is successfully saved.  This example code 
here should work, as the API for a Formset is very similar to a Form.

For more information on how to use class-based views, be sure to check out 
my latest blog post on the subject, it may provide some useful information 
on what functions to override:

http://www.pythondiary.com/blog/Nov.11,2012/mapping-out-djangos-class-based-views.html

Best Regards,
  Kevin Veroneau

On Friday, 9 November 2012 12:55:13 UTC-6, Lee Hinde wrote:
>
> I'm looking at these two blog posts to help me figure out nested formsets:
>
> http://yergler.net/blog/2009/09/27/nested-formsets-with-django/
>
> http://andreipetre.tumblr.com/post/26203496689/nested-formsets-with-django
>
> The example uses a function view and I was interested using class-based 
> views, but I can't figure out where to start.
>
> Thanks for any pointers.
>
>  - Lee
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/fAx0JHkuCOcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to