问题标签 [django-simple-history]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
41 浏览

python - 如何在 Django Admin 中显示更改的字段?

我有一个模型Managers和一个代理模型MyManagers。我试图在代理模型的管理面板中显示更改的字段,但Admin/history仅显示用户、日期和操作。如何解决?

我的models.py

我的admin.py

在此处输入图像描述

0 投票
1 回答
28 浏览

django - django-simple-history populate history when existing history present

After setting up history for a model using django-simple-history, I wanted to run populate_history to populate the history table based on the existing contents of the table. However, other users have already made a number of changes, causing the history table to be partially populated. Running populate_history --auto simply results in message Existing history found, skipping model.

I wish to retain the existing history, but populate history for all records not currently stored in the history. Is there a way to do this?

0 投票
0 回答
18 浏览

django - django-simple-history 如何获取相关的外键对象

我有一个名为的模型Order和另一个OrderItem. 该OrderItem表具有该表的外键Order。现在我在两个模型上都安装并设置了 [simple-history][1]。我尝试获取订单历史记录,并使用OrderItem表上的相关名称从历史记录中获取相关的 OrderItem,但它返回错误:

AttributeError:“HistoricalOrder”对象没有属性“order_items”

这是我的OrderOrderItem桌子。

以下命令给了我一个命令。

但是如果我运行,order.order_items.all()那么我会得到属性错误。

如果我在实际模型上运行查询,那么我会使用以下命令获取 order_items。

Order.objects.get(id=102).order_items.all()

是否可以像普通 django 模型一样从历史表中获取 order_items。我怎样才能做到这一点。

谢谢你。[1]:https ://django-simple-history.readthedocs.io/en/latest/index.html

0 投票
0 回答
12 浏览

python - django-simple-history,TemplateDoesNotExist 位于 /admin/shared_models/mannedsetting/1/history/simple_history/object_history.html

我正在使用 django-history-admin

我有模特课

然后在 admin.py

MannedSetting实例编辑页面出现历史按钮

但是,当单击按钮时,会出现此错误。

0 投票
0 回答
14 浏览

django - 'SimpleHistoryAdmin' 没有属性 _meta 问题

我安装了 django-simple-history
但它不起作用。
我尝试了python manage.py makemigrations ,但
速度低于错误。像 AttributeError: type object 'SimpleHistoryAdmin' has no attribute '_meta' 我想在 django-admin 中查看历史记录。

怎么了?????

0 投票
0 回答
12 浏览

python - 编辑变更历史模型 (django)

当我从 SimpleHistoryAdmin 继承时,会出现对象字段。当我从 admin.ModelAdmin 继承时,我可以将此字段添加到更改历史记录中吗?