在Django中建立模型完整历史的最佳方法是什么? [英] what its the best way to make full history for a model in django?

查看:76
本文介绍了在Django中建立模型完整历史的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为模型创建历史记录,以显示字段中的旧值和新更改的值?

How to make history for a model that show me the old value and the new changed value in a field?

在我看来,我认为要创建历史模型以每个具有相同字段的模型,当用户创建新模型或更新第一个模型的数据时,也转到第二个模型。

In my mind i think to make history model to each model which have the same fields and when the user create new or update the data from the first model go to the second model too.

我大量搜索了这个问题,我发现了一个叫做django-reversion的数据包,但是我不明白如何存储旧值和新值,如果有人可以帮助我解决这个问题,请告诉我。

I searched alot for this problem and i found a packet called django-reversion but i didn't understand it how to make it store the old value and new value if any one can help me for this problem please tell me.

推荐答案

为此,您可以使用简单历史记录应用程序

For this purpose you can use simple-history app

实例的每次更改都会反映在历史记录表中。每次更改都会有一个新行,其中包含新值。因此您可以重现每个字段的所有旧值。

Every changes of your instance will be reflected in historical table. There would be new row with new values for each changes. so you can reproduce all old values for each field.

这篇关于在Django中建立模型完整历史的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆