Wagtail "schedule_published_pages" 管理命令

Wagtail "schedule_published_pages" Management Command

我想知道为什么我预定的 posts 没有在 Wagtail 中自动运行,但我在文档中看到需要一个管理命令来实现这一点。我不熟悉编写自定义管理命令,我想知道如何让 python manage.py publish_scheduled_pages 命令每小时自动触发一次?

这段代码在文档树中的什么位置?是否有我只需要插入的代码,然后 运行s 从那里开始?还是服务器需要按计划 运行 这些命令?

如有任何帮助,我们将不胜感激。我在 Wagtail 的任何地方都找不到此功能的任何现有代码,我想知道为什么按钮在管理员中以安排 post,但功能尚未内置?

您可能熟悉管理命令,因为 python manage.py runservermakemigrations 以及 migrate 是管理命令。

您可以使用 python manage.py -h

查看 所有 个可用命令

publish_scheduled_pages 应该定期调用。表格 Wagtail docs:

This command publishes, updates or unpublishes pages that have had these actions scheduled by an editor. We recommend running this command once an hour.

可以通过多种方式定期执行命令。通过 crontab 可能是最常见的。要编辑 crontab:

$ crontab -e

添加(for every fist minute of the hour):

0 * * * * python /path/to/your/manage.py publish_scheduled_pages --settings=your.settings