Tuesday, May 31, 2011

Re: how to implement a data grid? (or populate inlineformset with initial data)

On Tuesday, 31 May 2011 15:20:11 UTC+1, snfctech wrote:
Thanks, Jayapal.

I was hoping there was a little less java/ more django way to do this
by utilizing a Django ModelForm or InlindeFormSet and rendering
partial views.

So am I missing the point of InlineFormSets?  Can these not be
populated with data so they can be used to edit a set of existing
records?

Thanks.

Tony

No, you're not missing the point - that is exactly what model formsets are for. But you haven't read the documentation very closely: InlineFormsets are meant for editing only those elements that are related via ForeignKey to a specific object, so it is that related object that you pass to the formset via the `instance` parameter. The documentation shows this clearly: https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#inline-formsets

If you want to edit the elements of a queryset that aren't necessarily all related to the same object, you just use a standard ModelFormset, which does take a `queryset` argument - again, as shown in the docs: https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#using-a-custom-queryset
--
DR.

--
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