I have a set of models that look like this:
class Page(models.Model): title = models.CharField(max_length=255) class LinkSection(models.Model): page = models.ForeignKey(Page) title = models.CharField(max_length=255) class Link(models.Model): linksection = models.ForeignKey(LinkSection) text = models.CharField(max_length=255) url = models.URLField()
and admin.py, which looks like this:
class LinkInline(admin.TabularInline): model = Link class LinkSectionInline(admin.TabularInline): model = LinkSection inlines = [ LinkInline, ] class PageAdmin(admin.ModelAdmin): inlines = [ LinkSectionInline, ]
My goal is to get an admin interface that allows me to edit everything on one page. The end result of this model is that things are generated as a + template that looks more or less similar:
<h1>{{page.title}}</h1> {% for ls in page.linksection_set.objects.all %} <div> <h2>{{ls.title}}</h2> <ul> {% for l in ls.link_set.objects.all %} <li><a href="{{l.url}}">{{l.title}}</a></li> {% endfor %} </ul> </div> {% endfor %}
I know that the inline-in-anline inline trick doesn't work in the Django admin, as I expected. Does anyone know how to enable such a three-level simulation? Thanks in advance.
python django django-models django-admin
The_OP Mar 31 '09 at 19:20 2009-03-31 19:20
source share