Admin Inline inside another admin inline

2,143 views
Skip to first unread message

Sean Brant

unread,
Jul 3, 2010, 1:46:03 PM7/3/10
to Django users
I have these models and model admins and I was hoping inlines = []
inside a admin.TabularInline would work, but it doesn't seem to.

################################################

class Size(models.Model):
pass

class Product(models.Model):
pass

class ProductType(models.Model):
title = models.CharField(_('title'), max_length=200)
product = models.ForeignKey(Product, verbose_name=_('product'))
sizes = models.ManyToManyField(Size, through='ProductSize')

class ProductSize(models.Model):
product_type = models.ForeignKey(ProductType,
verbose_name=_('product type'))
size = models.ForeignKey(Size, verbose_name=_('size'))
quantity = models.IntegerField()


class ProductSizeInline(admin.TabularInline):
model = Product Size


class ProductTypeInline(admin.TabularInline):
model = ProductType
inlines = (ProductSizeInline,)


class ProductAdmin(admin.ModelAdmin):
inlines = (ProductTypeInline,)

admin.site.register(Product, ProductAdmin)

################################################

Im not even sure if this is best way to display things, I would like
one main product edit screen that lets you attach "product types"
which have "sizes" to a "product", it seems jumping between a bunch of
screens is not good ux. Wondering if I need to create a custom view
for this? Thanks for any help.

Alessandro Ronchi

unread,
Aug 4, 2010, 10:11:38 AM8/4/10
to django...@googlegroups.com


2010/7/3 Sean Brant <brant...@gmail.com>


Im not even sure if this is best way to display things, I would like
one main product edit screen that lets you attach "product types"
which have "sizes" to a "product", it seems jumping between a bunch of
screens is not good ux. Wondering if I need to create a custom view
for this? Thanks for any help.

It's not possible to make nested inline.
I'm trying to do the same thing, with this solution:
http://packages.python.org/django-easymode/tree/index.html?highlight=inline#admin-support-for-model-trees-with-more-than-2-levels-of-related-items

But it doesn't work.
--
Alessandro Ronchi
http://www.soasi.com

Hobby & Giochi
http://hobbygiochi.com
http://www.facebook.com/hobbygiochi

Alessandro Ronchi

unread,
Aug 7, 2010, 5:17:53 AM8/7/10
to Django users
On 4 Ago, 16:11, Alessandro Ronchi <alessandro.ron...@soasi.com>
wrote:

> It's not possible to make nested inline.
> I'm trying to do the same thing, with this solution:http://packages.python.org/django-easymode/tree/index.html?highlight=...

I solved my issue: I didn't notice the related things are available
only after saving the parent product.
I think it's a pretty good solution. You can try it.

Alessandro Ronchi
Reply all
Reply to author
Forward
0 new messages