跟踪 Django 模型实例的更改
当您在 Django 管理中创建或修改对象实例时,会创建一个更改日志条目。出于相当明显的原因,这确实很好。
然而,我的模型的实例是由管理界面之外的普通用户创建的。没有记录更改日志来记录其创建(不是一个大问题),但我想跟踪用户所做的编辑。
我还想在前端向用户显示完整的日志(用户+管理员编辑),所以我需要一种方法来提取更改日志。
我的问题:如何?是否有一个单行开关我可以轻按以启用完整日志记录,或者我是否必须深入研究并在用户的编辑表单逻辑上执行某些操作?
When you create or modify an object instance in Django's admin, a changelog entry is created. This is really nice for fairly obvious reasons.
However my model's instances created by a normal user outside of the admin interface. No changelog is recorded to note its creation (not a huge issue) but I would like to track edits the user makes.
I also want to show the user this full log (user+admin edits) in the frontend so I need a way to pull the changelog out.
My question: how? Is there a one-line switch I can flick to enable full logging or do I have to dig in and do something on my user's edit form logic?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
django-reversion 是一款旨在帮助解决此问题的应用程序。
django-reversion is an app designed to help with that.