0

我需要更改变形验证错误消息

'There was a problem with your submission Errors have been highlighted below'.

如何自定义我自己的错误消息或隐藏此错误消息?

在此处输入图像描述

4

1 回答 1

0

您可以覆盖 Deform 使用的任何 Chameleon 模板

要确定要覆盖的模板,请在 Deform 包源代码中搜索您要修改的字符串,在本例中,“您的提交存在问题”。你会发现templates/form.pt

在你的包的根目录中创建一个目录,比如说templates/_deform/,保存你的模板覆盖。

在您的 Pyramid 应用程序中,指定您存储模板覆盖的位置。然后在您的应用程序中__init__.py

from deform.renderer import configure_zpt_renderer

# other stuff

def main(global_config, **settings):

    # configuration stuff

    configure_zpt_renderer(["mypackage:templates/_deform"])

最后将模板form.pt从变形包复制到您创建的覆盖文件夹。此模板将覆盖变形默认值。根据需要编辑其字符串。

如果您使用国际化,则应改为编辑语言的翻译文件,而不是按照上述过程。

于 2019-12-19T07:45:48.900 回答