【发布时间】:2021-12-26 18:56:36
【问题描述】:
我的代码:
from django.core.validators import RegexValidator
URL_VALIDATOR_MESSAGE = 'Not a valid URL'
URL_VALIDATOR = RegexValidator(regex='http\D+', message=URL_VALIDATOR_MESSAGE)
class SezPubBlock(blocks.StructBlock):
sez = blocks.ListBlock(
blocks.StructBlock(
[
("title", blocks.CharBlock(classname="full title", icon="title", required=True)),
("url", blocks.URLBlock(required=True, validators=[URL_VALIDATOR])),
], label="Link", icon="link"
), label="Link sezione"
)
我需要插入的链接:http://intranet/example/ 链接没有点并且匹配正则表达式 'http\D+' 但是当我保存页面时,会出现默认错误“输入有效的 URL。”
如果我添加“.com”http://intranet.com/example/,则有效。 我认为默认验证器没有被覆盖
【问题讨论】:
标签: django-models wagtail wagtail-streamfield