Django 1.9 Admin Site History - How to display both previous value and changed value of a field?

时间:2016-07-11 19:19:03

标签: django django-admin

Using Django 1.9's Admin site, it is possible to view the change history for Model objects using the History button. When a change is made and logged in History, right now it only shows me the Action, for example "Changed description." is there a way to customize the fields in the History list to show the previous value of the field as well as what it was changed to? For example, "Changed x to y." Thank you!

2 个答案:

答案 0 :(得分:1)

Django-admin does not offer a full-featured auditing history of your models. Instead you have to rely to a app like django-reversion (https://github.com/etianen/django-reversion) or django-simple-history (https://github.com/treyhunner/django-simple-history). One difference between these is that django-reversion keeps a JSON object for each version of the file, while django-simple-history creates a seperate history table - so django-reversion has a more compact representation of each version while django-simple-history offers easier older version querying.

I've also written an introductionary article about django-model auditing that may be useful @ https://spapas.github.io/2015/01/21/django-model-auditing/

答案 1 :(得分:-1)

Django确实记录了所做的更改。如果您想在django_admin_log中访问该历史记录,则可以将其添加到您自己的管理员中

http://djangoweekly.com/blog/post/viewbrowse-all-django-admin-edits-recent-actions-listing