python - 编辑 django wagtail 提升标签字段
问题描述
您好,我想问您有关在django wagtail cms v.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'),
]
问题描述图片:
解决方案
这是在现有默认字段之间添加新字段的方法,尤其是在您询问的“推广”选项卡中:
主页/models.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"),
]
推荐阅读
- google-cloud-storage - 谷歌云存储 java 客户端为 getContent 设置超时
- java - 找不到提供程序 (ClassNotFoundException) maven 项目
- r - 如何从一个值(名称到名称)选择数据框中的行到另一个
- c++ - 以“需要表达式”的方式来看,未计算的操作数是什么?
- html - 2020 年在网站上发布电子邮件地址时,混淆电子邮件地址的正确方法是什么?
- mongodb - MongoDB:分组,然后计算不同的值
- sql - 在 SqlDbx 和 SQL Server 上选择抛出不同的结果,可能是什么原因?
- android - Jetpack 原型数据存储 - 使用 Kotlin dsl 进行 gradle 配置
- java - 使用 Kotlin 创建关键路径算法
- geopandas - Geopandas:将单个多边形转换为多多边形,保持单个多边形拓扑?