django-data-history


Namedjango-data-history JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryA Django application that allows you to store detailed data in the change log and display the detailed information in object's history view.
upload_time2024-11-17 10:32:47
maintainerrRR0VrFP
docs_urlNone
authorrRR0VrFP
requires_pythonNone
licenseApache License, Version 2.0
keywords django django data history
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```shell
pip install django-data-history
```

## Usage

```python

## 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.

```python
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开源协议。

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-data-history",
    "maintainer": "rRR0VrFP",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django, django data history",
    "author": "rRR0VrFP",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/27/31/22505b6eecd87182bbc948e8e7a036eff9165d6bba314241b9ac9989fdbb/django-data-history-0.2.0.tar.gz",
    "platform": null,
    "description": "# django-data-history\n\nA Django application that allows you to store detailed data in the change log and display the detailed information in object's history view.\n\n## Install\n\n```shell\npip install django-data-history\n```\n\n## Usage\n\n```python\n\n## add app: django_middleware_global_request\n## add app: django_middleware_request_id\n## add app: django_static_jquery_ui\n## add app: django_data_history\n## put django_data_history before django.contrib.admin\n\nINSTALLED_APPS = [\n    ...\n    \"django_middleware_global_request\",\n    \"django_middleware_request_id\",\n    \"django_static_jquery_ui\",\n    'django_data_history',\n    ...\n    'django.contrib.admin',\n    ...\n]\n\n## add middleware: django_middleware_global_request.middleware.GlobalRequestMiddleware\n## add middleware: django_middleware_request_id.middlewares.DjangoMiddlewareRequestId\nMIDDLEWARE = [\n    ...\n    \"django_middleware_global_request.middleware.GlobalRequestMiddleware\",\n    \"django_middleware_request_id.middlewares.DjangoMiddlewareRequestId\",\n    ...\n]\n\n# default to False, so you must set it to True to enable all models injection.\nSAVE_DATA_HISTORIES_FOR_ALL = True \n\n# if SAVE_DATA_HISTORIES_FOR_ALL==False, then only these models will be injected.\n# default to empty.\nSAVE_DATA_HISTORIES_FOR = [\n    \"your_app1.model_name1\"\n]\n\n# if SAVE_DATA_HISTORIES_FOR_ALL==True, these models will NOT be injected.\n# default to:\n# [\n#    \"sessions.session\",\n#    \"contenttypes.contenttype\",\n#    \"admin.logentry\",\n#    \"auth.permission\",\n# ]\nDO_NOT_SAVE_DATA_HISTORIES_FOR = [\n    \"your_app2.model_name2\",\n]\n\n```\n\n## Deep usage\n\n### How to ignore some fields' values?\n\nSome fields' value are inessential so that we want to ignore their changes.\nSimply add django_data_history_excludes in the model.\n\n```python\nclass TestModel(models.Model):\n\n    django_data_history_excludes = [\"mod_time\"]\n\n    mod_time = models.DateTimeField(auto_now=True)\n```\n\nIf only mod_time changed, we are not treat the event as a change event, so that we will not make a new record.\n\n### How to save data history in separate table?\n\nSimply add `DATA_HISTORY_STORAGE_CLASS` property to the model class.\nA new `DATA_HISTORY_STORAGE_CLASS` must a subclass of `django_data_history.models.DataHistoryBase`.\nA `DATA_HISTORY_STORAGE_CLASS` can be a real class or a `absolute-dot-path` to the real class.\n\n### \n\n\n## Releases\n\n### v0.1.0\n\n- First release.\n\n### v0.1.1\n\n- Fix ugettext_lazy problem.\n\n### v0.1.2\n\n- Add save_data_histories_for_fk_instance to fix inline edit history missing problem.\n\n### v0.1.3\n\n- Fix problems that field name has \"+\" in fields_map.\n\n### v0.1.5\n\n- Using django_middleware_request_id instead of implement request_id inside the app.\n\n### v0.1.6\n\n- Fix requirements in setup.py.\n\n### v0.1.7\n\n- Fix DataHistoryModelAdmin.get_data_histories function problem.\n\n### v0.1.8\n\n- Fix problems in working together with django-import-export.\n- Add django_data_history_excludes support.\n\n### v0.1.9\n\n- Fix OneToOneField problem.\n\n### v0.2.0\n\n- \u4f7f\u7528Apache License, Version 2.0\u5f00\u6e90\u534f\u8bae\u3002\n",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0",
    "summary": "A Django application that allows you to store detailed data in the change log and display the detailed information in object's history view.",
    "version": "0.2.0",
    "project_urls": null,
    "split_keywords": [
        "django",
        " django data history"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9fcbf44a5efa04817eb6da9de28d7308e7bc479a9e2f31807138c37bcd46697f",
                "md5": "438ac7c0e43373f9856c38bc84f77a6c",
                "sha256": "221a3e3f944203aa5053e8c6196fd0ce81f5334e83e0a5325e9c350ce56fbdcc"
            },
            "downloads": -1,
            "filename": "django_data_history-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "438ac7c0e43373f9856c38bc84f77a6c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 19498,
            "upload_time": "2024-11-17T10:32:45",
            "upload_time_iso_8601": "2024-11-17T10:32:45.664427Z",
            "url": "https://files.pythonhosted.org/packages/9f/cb/f44a5efa04817eb6da9de28d7308e7bc479a9e2f31807138c37bcd46697f/django_data_history-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "273122505b6eecd87182bbc948e8e7a036eff9165d6bba314241b9ac9989fdbb",
                "md5": "1f25f601219195dfbc8b7b0cefe3e427",
                "sha256": "c923967b89059a32ca35255247ecdaf83b09437302b13ee614d55388b0b56d45"
            },
            "downloads": -1,
            "filename": "django-data-history-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1f25f601219195dfbc8b7b0cefe3e427",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 17113,
            "upload_time": "2024-11-17T10:32:47",
            "upload_time_iso_8601": "2024-11-17T10:32:47.419380Z",
            "url": "https://files.pythonhosted.org/packages/27/31/22505b6eecd87182bbc948e8e7a036eff9165d6bba314241b9ac9989fdbb/django-data-history-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-17 10:32:47",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "django-data-history"
}
        
Elapsed time: 1.44327s