如何将内联可订购模型添加到 Wagtail 代码段?

How can I add an inline orderable model to a Wagtail Snippet?

我希望能够将内联可订购模型添加到 Wagtail 代码段。下面的代码给我一个错误,说我必须为 ClusterableModel 使用 ParentalKey。请指教

@register_snippet
@python_2_unicode_compatible
class NavCategory(models.Model):
    title = models.CharField(max_length=200)

    panels = [
        FieldPanel('title'),
        InlinePanel('nav_item', label='Pages')
    ]

    def __str__(self):
        return self.title

    class Meta:
        verbose_name_plural = 'nav categories'
        ordering = ['title']


class NavItem(Orderable):
    category = ParentalKey(
        'core.NavCategory',
        related_name='nav_item'
    )
    link = models.ForeignKey(
        'wagtailcore.Page',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )

    panels = [
        PageChooserPanel('link')
    ]

    def __str__(self):
        return self.category.title + ' -> ' + self.nav_item.link

    class Meta(Orderable.Meta):
        verbose_name = 'Nav Item'
        verbose_name_plural = 'Nav Items'

NavCategory需要继承自modelcluster.models.ClusterableModel:

from modelcluster.models import ClusterableModel

class NavCategory(ClusterableModel):
    ...