Skip to main content

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.

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.

v0.1.9

  • Fix OneToOneField problem.

v0.2.0

  • 使用Apache License, Version 2.0开源协议。

Release files for django-data-history 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-data-history 0.2.0
File Size Uploaded
django-data-history-0.2.0.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-data-history 0.2.0
File Interpreter ABI Platform
django_data_history-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.6 kB

Release files / django-data-history-0.2.0.tar.gz

Download URL django-data-history-0.2.0.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c923967b89059a32ca35255247ecdaf83b09437302b13ee614d55388b0b56d45
BLAKE2b-256 checksum
How to use checksums
273122505b6eecd87182bbc948e8e7a036eff9165d6bba314241b9ac9989fdbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release files / django_data_history-0.2.0-py3-none-any.whl

Download URL django_data_history-0.2.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
221a3e3f944203aa5053e8c6196fd0ce81f5334e83e0a5325e9c350ce56fbdcc
BLAKE2b-256 checksum
How to use checksums
9fcbf44a5efa04817eb6da9de28d7308e7bc479a9e2f31807138c37bcd46697f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page