A Django application that allows you to store detailed data in the change log and display the detailed information in object's history view.
Project description
django-data-history
A Django application that allows you to store detailed data in the change log and display the detailed information in object's history view.
Install
pip install django-data-history
Usage
## add app: django_middleware_global_request
## add app: django_middleware_request_id
## add app: django_static_jquery_ui
## add app: django_data_history
## put django_data_history before django.contrib.admin
INSTALLED_APPS = [
...
"django_middleware_global_request",
"django_middleware_request_id",
"django_static_jquery_ui",
'django_data_history',
...
'django.contrib.admin',
...
]
## add middleware: django_middleware_global_request.middleware.GlobalRequestMiddleware
## add middleware: django_middleware_request_id.middlewares.DjangoMiddlewareRequestId
MIDDLEWARE = [
...
"django_middleware_global_request.middleware.GlobalRequestMiddleware",
"django_middleware_request_id.middlewares.DjangoMiddlewareRequestId",
...
]
# default to False, so you must set it to True to enable all models injection.
SAVE_DATA_HISTORIES_FOR_ALL = True
# if SAVE_DATA_HISTORIES_FOR_ALL==False, then only these models will be injected.
# default to empty.
SAVE_DATA_HISTORIES_FOR = [
"your_app1.model_name1"
]
# if SAVE_DATA_HISTORIES_FOR_ALL==True, these models will NOT be injected.
# default to:
# [
# "sessions.session",
# "contenttypes.contenttype",
# "admin.logentry",
# "auth.permission",
# ]
DO_NOT_SAVE_DATA_HISTORIES_FOR = [
"your_app2.model_name2",
]
Deep usage
How to ignore some fields' values?
Some fields' value are inessential so that we want to ignore their changes. Simply add django_data_history_excludes in the model.
class TestModel(models.Model):
django_data_history_excludes = ["mod_time"]
mod_time = models.DateTimeField(auto_now=True)
If only mod_time changed, we are not treat the event as a change event, so that we will not make a new record.
How to save data history in separate table?
Simply add DATA_HISTORY_STORAGE_CLASS
property to the model class.
A new DATA_HISTORY_STORAGE_CLASS
must a subclass of django_data_history.models.DataHistoryBase
.
A DATA_HISTORY_STORAGE_CLASS
can be a real class or a absolute-dot-path
to the real class.
Instance's history view image
Releases
v0.1.0
- First release.
v0.1.1
- Fix ugettext_lazy problem.
v0.1.2
- Add save_data_histories_for_fk_instance to fix inline edit history missing problem.
v0.1.3
- Fix problems that field name has "+" in fields_map.
v0.1.5
- Using django_middleware_request_id instead of implement request_id inside the app.
v0.1.6
- Fix requirements in setup.py.
v0.1.7
- Fix DataHistoryModelAdmin.get_data_histories function problem.
v0.1.8
- Fix problems in working together with django-import-export.
- Add django_data_history_excludes support.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-data-history-0.1.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e95324635075055c16cc4b2879ac157bf1d1518f1b4d919278b6e2d3fc11365 |
|
MD5 | dadb4ccc900703943485c199ac6fe866 |
|
BLAKE2b-256 | e4b02b61828b1c223254ecf80421e2fb2bfda1055d1fbdf57b66d187a25bb99c |
Hashes for django_data_history-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 700c472243b08589a4090ae150eb780c3701662fb11f8e072bc767936e8bbacc |
|
MD5 | 7334ca6253ca489702c0f4377e74f928 |
|
BLAKE2b-256 | 78239e7698e22c72d9565caa3f8c85e044a7f55add3a3197ce120a3ea45c0c47 |