My Django model is as follow:
class Page(models.Model):
title = models.CharField(max_length=200)
class Section(models.Model):
page_id = models.ForeignKey(Page)
title = models.CharField(max_length=200)
class SubSection(models.Model):
section_id = models.ForeignKey(Section)
title = models.CharField(max_length=200)
And I’d like to add a new Page in django Admin with the possibility to add several Section in which I can add several SubSection.
I already succeed to create a page where we can add a Page in which we can add several Section but it asks only for the name of the Section and there is no possibility to add a SubSection in the same page.
I tried this:
class SectionInline(admin.TabularInline):
model = Section
extra = 3
class PageAdmin(admin.ModelAdmin):
inlines = [SectionInline]
admin.site.register(Page, PageAdmin)
But I can not add SubSectionInline into SectionInline.
Is there a way to do this?
Thank you.
Unfortunately you can’t do this using standard django admin app.
All django admin let you do is to add Page with many Sections.
Maybe adding many SubSections in Sections adding page would do what you want?
You need to add: