编辑Django wagtail升级选项卡字段

2024-05-14 05:49:01 发布

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

您好,我想问您关于在django wagtail cms版本2.6.1中编辑默认的“升级”选项卡的问题。我正在做双语网站,我想把额外的翻译字段“页面标题CZ”和“搜索描述CZ”之间现有的默认字段。正如您在所附图片上看到的,我知道如何在另一个FieldPanel中添加额外的字段,但这并不是我所需要的。你知道吗

另一个FieldPanel的代码:

class BlogPage(Page):
    template = "blog/blog.html"  
    subpage_types = ['blog.BlogPostPage','blog.PostAdvancedPage']

    menu_order = models.IntegerField(default = 0)

    promote_panels = Page.promote_panels + [
       FieldPanel('menu_order'),
   ]

问题描述图像:

enter image description here


Tags: django版本编辑cms网站pageorderblog
1条回答
网友
1楼 · 发布于 2024-05-14 05:49:01

这是如何在现有默认字段之间添加新字段,特别是在您所查询的“升级”选项卡中:

家/型号.py你知道吗

from django.db import models

from wagtail.core.models import Page
from wagtail.admin.edit_handlers import MultiFieldPanel, FieldPanel

class HomePage(Page):
    page_title_CZ           = models.CharField(
                                    max_length=255, 
                                    blank=True, 
                                    null=True, 
                                    help_text='Page title in language of your choice')
    search_description_CZ   = models.CharField(
                                    max_length=255, 
                                    blank=True, 
                                    null=True, 
                                    help_text='Search Description in language of your choice')

    COMMON_PANELS = (
        FieldPanel('slug'),
        FieldPanel('seo_title'),
        FieldPanel('page_title_CZ'),
        FieldPanel('show_in_menus'),
        FieldPanel('search_description'),
        FieldPanel('search_description_CZ'),

        # add fields in any position you feel you have need for
    )

    promote_panels = [
        MultiFieldPanel(COMMON_PANELS, heading="Common page configuration"),
    ]



结果: enter image description here

相关问题 更多 >