有人能告诉我我做错了什么吗?因为,这是和平迁移2天b

2024-10-04 03:15:41 发布

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

有人能告诉我我到底做错了什么,因为它不断弹出AttributeError:type object'HomePage'没有属性'landing'。你知道吗

relatedlink对象已正确配置,以便主页登陆和主页支持从中继承并利用其实例和属性。你知道吗

# Home Page
class HomePageLanding(Orderable, RelatedLink):
    page = ParentalKey('ibro.HomePage', related_name='landing')
    colour = models.CharField(max_length=255)
    background = models.ForeignKey(
        'ibro.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    logo = models.ForeignKey(
        'ibro.IbroImage',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    text = models.CharField(
        max_length=255
    )

    panels = RelatedLink.panels + [
        ImageChooserPanel('background'),
        ImageChooserPanel('logo'),
        FieldPanel('colour'),
        FieldPanel('text'),
    ]


class HomePageSupports(Orderable, RelatedLink):
    page = ParentalKey('ibro.HomePage', related_name='supports')
    image = models.ForeignKey(
        'ibro.IbroImage',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    panels = RelatedLink.panels + [
        ImageChooserPanel('image')
    ]


class HomePage(Page):
    hero_intro_primary = models.TextField(blank=True)
    hero_intro_secondary = models.TextField(blank=True)
    intro_body = RichTextField(blank=True)
    socialmedia_title = models.TextField(blank=True)
    blog_title = models.TextField(blank=True)
    supports_title = models.TextField(blank=True)

    class Meta:
        verbose_name = "Homepage"

    content_panels = [
        FieldPanel('title', classname="full title"),
        MultiFieldPanel(
            [
                FieldPanel('landing_intro_primary'),
                FieldPanel('landing_intro_secondary'),
            ],
            heading="Landing intro"
        ),
        InlinePanel('landing', label="Landing"),
        FieldPanel('intro_body'),
        FieldPanel('Socialmedia_title'),
        FieldPanel('blog_title'),
        FieldPanel('supports_title'),
        InlinePanel('supports', label="Supports"),
    ]

Tags: nametruetitlemodelsclasstextfieldhomepagerelated