What's the straightforward way to implement one to many editing in list_editable in django admin?

Posted by Nate Pinchot on Stack Overflow See other posts from Stack Overflow or by Nate Pinchot
Published on 2012-08-30T16:46:09Z Indexed on 2012/09/07 15:38 UTC
Read the original article Hit count: 243

Given the following models:

class Store(models.Model):
    name = models.CharField(max_length=150)

class ItemGroup(models.Model):
    group = models.CharField(max_length=100)
    code = models.CharField(max_length=20)

class ItemType(models.Model):
    store = models.ForeignKey(Store, on_delete=models.CASCADE, related_name="item_types")
    item_group = models.ForeignKey(ItemGroup)
    type = models.CharField(max_length=100)

Inline's handle adding multiple item_types to a Store nicely when viewing a single Store.

The content admin team would like to be able to edit stores and their types in bulk. Is there a simple way to implement Store.item_types in list_editable which also allows adding new records, similar to horizontal_filter? If not, is there a straightforward guide that shows how to implement a custom list_editable template? I've been Googling but haven't been able to come up with anything.

Also, if there is a simpler or better way to set up these models that would make this easier to implement, feel free to comment.

© Stack Overflow or respective owner

Related posts about python

Related posts about django