在 Django Admin 中实现工作流程 - Django
我有一个很好的管理面板设置,以便用户可以管理网站内的数据。
问题是我需要实现一个工作流程,因此保存的模型可以在各个阶段获得批准,然后最终发布。
由于有问题的模型只是一个,我想添加一个布尔“approved_for_publishing”字段和一个“approved_by”manytomany 字段。
障碍是将其集成到管理面板中。
如果有人对这个主题有一些意见,那就太棒了。 =)
I have a nice admin panel setup so users can manage the data within the site.
Problem is that I need to implement a workflow, so saved models can be approved from and to various stages, to then be finally published.
As the model in question is just one, I thougth of adding a boolean 'approved_for_publishing' field and a 'approved_by' manytomany field.
The obstancle is integrating this within the admin panel.
If someone has a few opinions on the topic that would be really awesome. =)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
早些时候我完成了类似的功能。这是您需要做的:
创建一个批准状态模型,并具有不同的批准变体,即每个模型对象代表不同的批准阶段。此外,您还必须有一个 StatusHistory 模型,它反映您的文章(例如)的当前状态。
因此,当您在管理员中更改文章的状态时,会创建一个新的 StatusHistory 对象,并为旧对象提供 current=False 变量。
这种方法看起来有点笨重,但是当您实现它时,您所需要的一切很容易陷入 ORM:状态历史记录只是所有对象的列表,对工作流的更改仅涉及创建新的审批状态和更改硬编码的状态流程例程
Some time early I completed similar functionality. Here is what you need to do:
Create an approval status model, and have different variants of approval, i.e each model object represents different approval stage.Also you must have a StatusHistory model which reflects what current status does your article(for example) has.
So when in your admin you change the status of the article, a new StatusHistory object is created and old object is given current=False variable.
This approach seems a bit bulky, but when you implement it, all you need easily falls into ORM: status history is just a list of all objects, changes to workflow involve only creating new approval status and changing your hardcoded status flow routines
django-werewolf 正是您正在寻找的(https://pypi.python.org/pypi /django-werewolf)。
在此处检查示例应用程序(https://bitbucket.org/barseghyanartur/django-werewolf/src)。
如有任何问题和支持,请联系我。
django-werewolf is exactly what you're looking for (https://pypi.python.org/pypi/django-werewolf).
Check the example app here (https://bitbucket.org/barseghyanartur/django-werewolf/src).
For any questions and support, contact me.