如何实施站点特定标签?
How might one implement Site-specific Tags?
我的代码商店正在开发一个多租户 Wagtail 站点,我们希望每个站点都有自己的一组标签。我们希望这样,站点 A 的用户定义的标签不会出现在自动完成程序或站点 B 的用户的 "popular tags" 列表中。
custom Tag model 可以吗?我在想我们可以在标签的 slugs 前加上当前站点的主机名,然后在为 "popular tags" 列表或自动完成器提取标签时根据该前缀过滤它们。
如果目前无法做到这一点,是否可以对 Wagtail 进行猴子修补以支持它?如果是这样,可能需要更改哪些代码?
自定义标签模型是可行的方法,是的。您目前必须解决的一个问题(记录在此处:https://github.com/wagtail/wagtail/issues/3577) is that the autocomplete view is hard-coded to use the default tag model, so to use a custom one you'd need to duplicate that view in your own app, along with the AdminTagWidget
引用了它。
我的代码商店正在开发一个多租户 Wagtail 站点,我们希望每个站点都有自己的一组标签。我们希望这样,站点 A 的用户定义的标签不会出现在自动完成程序或站点 B 的用户的 "popular tags" 列表中。
custom Tag model 可以吗?我在想我们可以在标签的 slugs 前加上当前站点的主机名,然后在为 "popular tags" 列表或自动完成器提取标签时根据该前缀过滤它们。
如果目前无法做到这一点,是否可以对 Wagtail 进行猴子修补以支持它?如果是这样,可能需要更改哪些代码?
自定义标签模型是可行的方法,是的。您目前必须解决的一个问题(记录在此处:https://github.com/wagtail/wagtail/issues/3577) is that the autocomplete view is hard-coded to use the default tag model, so to use a custom one you'd need to duplicate that view in your own app, along with the AdminTagWidget
引用了它。