管理员在one2one字段上内联

时间:2012-10-03 17:28:31

标签: django django-admin

我有三个django模型,我想在订单页面上编辑项目的实例。有可能吗?

#models.py

class Item(models.Model):
    name = models.CharField(max_length = 128)
    cart = models.ForeignKey('Cart')

class Cart(models.Model):
    number = models.IntegerField()

class Order(models.Model):
    cart = models.OneToOneField('Cart')

#admin.py

ItemInline(admin.TabularInline):
    model = Item

CartInline(admin.TabularInline):
    model = Cart

Order(ModelAdmin):
    inlines = (CartInline,) # I need ItemInline here...

1 个答案:

答案 0 :(得分:0)

这样做订单是推车的内联,而不是反过来?