可以扩展或覆盖Wagtail视图吗?

huangapple go评论55阅读模式
英文:

Is it possible to extend or override Wagtail views?

问题

我对在我的Wagtail博客中添加一些功能以在发布文章时自动发布到社交媒体感兴趣。通常,这应该在视图中完成。

我在GitHub上找到了一个名为wagtail_share_social的应用程序,但已经有2年没有更新了,我宁愿不依赖于第三方解决方案。

Wagtail文档中有关于扩展视图的说明,但它们似乎仅限于扩展管理视图,或者用于仪表板的视图,而不是用于为非登录用户提供页面的视图。

是否可能扩展或覆盖Wagtail用于提供非管理员页面的视图?如果不行,那么在通过Wagtail提供页面时添加功能的正确方法是什么?

英文:

I'm interested in adding some functionality to my wagtail blog to automatically post to social media when a post is published. Normally, the place to do this would be in the view.

I did find an app on github called wagtail_share_social but it has not been updated in 2 years, and I would rather not be reliant on a third party solution.

The Wagtail documentation has notes on extending views, but they seem to be limited to extending admin views, or views used in the dashboard rather than for serving up pages to non-logged in users.

Is it possible to extend or override the Wagtail views for serving non admin pages? If not, what would be the correct approach to add functionality when a page is served via Wagtail?

答案1

得分: 1

最好的方法可能是使用“after_page_published”挂钩,并将您的社交媒体发布代码放在那里。参考链接:https://docs.wagtail.org/en/latest/reference/hooks.html#after-publish-page

英文:

The best way to do this is probably to use the "after_page_published" hook and put your social media publishing code there https://docs.wagtail.org/en/latest/reference/hooks.html#after-publish-page

huangapple
  • 本文由 发表于 2023年6月16日 00:53:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76483903.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定