Saturday, July 30, 2011

Nested formsets at Django 1.3

Hello List,

I've been upgrading an old Django 1.1.x app to use Django 1.3, and am
having a problem with nested formsets.

The structure of my formsets is based on the structure outline in
Nathan Yerger's blog post http://yergler.net/blog/2009/09/27/nested-
formsets-with-django/
, i.e. I have a grandparent object with a one to
many relation to its child objects, and each of these child objects has
a one to many relation to its children.

This worked fine in Django 1.1.x, but at 1.3 the forms in the lowest
layer always have is_bound = False, even after being rendered and
POSTed back to the view. Consequently validation always fails and the
objects that the forms represent cannot be updated. I've reproduced
the behaviour using the code from Nathan's blog post, so it seems that
this approach to nesting formsets is no longer valid, or the code needs
a tweak to work at 1.3.

Has anyone successfully used Nathan's code at 1.3, or is anyone able to
point me towards a nested formset implementation that works at this
release?

(Sorry about the absence of code examples - Nathan's post is much
clearer than my code, so I'd recommend you look at that.)

Cheers,

Kev

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment