This blog post recently really helped me out with figuring this out:
http://collingrady.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/
It actually is amazingly simple once you get what is going on.
On Mon, Mar 3, 2008 at 5:23 PM, Steve Potter <[EMAIL PROTECTED]> wrote:
>
> I am in the process of building a replacement admin change_list for
> one of my models. My goal is to allow some of the more common fields
> to be edited on the change_list page as opposed to having to click on
> each individual to make changes.
>
> So, I have a basic model:
>
> class Site(models.Model):
> name = models.CharField(max_length=100)
> url = models.URLField(null=True, blank=True)
> category = models.ForeignKey(Category, null=True, blank=True)
> notes = models.TextField(null=True, blank=True)
>
> and I have created a basic form with the fields I would like to be
> able to edit on the change_list page:
>
> class SiteChangeListForm(ModelForm):
> class Meta:
> model = Site
> fields = ('category', 'notes')
>
> so I know that I can create an instance with the appropriate default
> values by doing something like this:
> siteobject = Site.objects.get(pk=1)
> form = SiteChangeListForm(instance=siteobject)
>
> Then I could include that instance in my context.
>
> However, I am using the object_list generic view and I would like a
> form instance with appropriately populated for each object. So I can
> do something like this:
>
> {{ for site in object_list }}
>
> <div>Category: {{ site.form.category }}</div>
> <div>Notes: {{ site.form.category }}</div>
>
> {{ endfor }}
>
> I guess I am just at a loss as to how I would create the appropriate
> instances of the form and make them available in the context. Any
> help would be appreciated.
>
> Thanks,
>
> Steve
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---