【发布时间】:2022-01-14 11:30:06
【问题描述】:
我正在尝试根据类别、国家和城市为占星家制作鹡鸰页面。 我的网址是:
https//localhost:8080/<category>
https//localhost:8080/<category>/<country>
https//localhost:8080/<category><country>/<city>
如果我尝试使用“/”正斜杠保存 url,那么它会从 slug 中删除“/”并将其保存为字符串。
Ex: <category><country>/<city> to categorycountrycity
那么是否可以将 wagtail 默认页面 slug 类型“SlugField”覆盖为“CharField”。 还是有其他解决方案?
【问题讨论】:
-
斜线不会成为 slug 的一部分。为什么不定义
<category>/<country>/<city>/? -
如果你使用
<category><country>,那么category会“吃掉”除了最后一个字符之外的所有字符,然后country会得到最后一个字符,所以cat1usa会分配@987654328 @到category. -
您所描述的内容听起来根本不像标准的 Wagtail 行为 - 普通的 Wagtail 页面总是使用斜杠来分隔路径元素,并且没有配置此选项的选项。您在使用
RoutablePageMixin吗?如果是这样,请分享您的代码。
标签: django wagtail django-cms