Wagtail:将Orderable类添加到Orderable类

2024-04-25 05:28:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个使用Orderable类的片段。我想在第一个医嘱内容中添加另一个医嘱内容类。例如:

models.py:

@register_snippet
class LocationHours(ClusterableModel):
    location = models.CharField(
        max_length=255,
        blank=True,
        help_text='Location for this set of Hours.'
    )

    panels = [
        MultiFieldPanel([
            FieldPanel('location'),
            InlinePanel('location_hours'),
        ], "Hours"),
    ]

class Hours(Orderable):
    snippet = ParentalKey('LocationHours', related_name='location_hours', on_delete=models.CASCADE)

    ...

    panels = [
        ...
        InlinePanel('hours_override', label="Hours Overrides"),
    ]

class HoursOverride(Orderable):
        orderable = ParentalKey('Hours', related_name='hours_override', on_delete=models.CASCADE)

我该怎么做呢?你知道吗


Tags: name内容modelslocationsnippetclassrelatedpanels