django_history
Django_history - a module for tracking changes to model instances.
Install
pip3 install git+https://github.com/QuantumaStelata/django-history.git
Add to INSTALLED_APPS
INSTALLED_APPS = [
...
'django_history'
...
]
Do migrations
python3 manage.py migrate
Create a model
class Task(models.Model):
...
Add mixin to your model
from django_history.mixins import HistoryMixin
class Task(HistoryMixin):
...
Note:
using a HistoryMixindoesn't need to be migrated
Congrats, history is being recorded
For flexible use, write in the settings.py
# A function that returns the user who made the request.
# NOTE: function must not have arguments.
HISTORY_GET_CURRENT_USER
# If true then the history object will be saved asynchronously using celery_app.
# WARNING: history recording uses pickle serializer.
HISTORY_ALLOW_CELERY
# If you are deleting objects programmatically,
# pass in a list of field names that store information about deleting the object
# to more accurately create a history object.
HISTORY_SOFT_DELETE_FIELDS
For example
- Using soft delete model
# models.py
class Task(HistoryMixin):
...
deleted_at = models.DateTimeField(null=True)
...
# settings.py
# Pass soft delete field in HISTORY_SOFT_DELETE_FIELDS
HISTORY_SOFT_DELETE_FIELDS = ['deleted_at']
- If you use django-currentuser, pass get_current_user function to HISTORY_GET_CURRENT_USER
# settings.py
from django_currentuser.middleware import get_current_user
HISTORY_GET_CURRENT_USER = get_current_user
Metadata
Release files for django-histories 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_histories-1.0.2.tar.gz | 6.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_histories-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.4 kB
Release files / django_histories-1.0.2.tar.gz
| Download URL | django_histories-1.0.2.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75d9c5a4310e7efa5d7de114da730ca1c799bebb190a2183ade47f12c6dabca1
|
|
BLAKE2b-256 checksum How to use checksums |
84f31f7270dfe44b48a0db972b0642317b3cb7fe698cbef0af9e4113f8c3fae0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / django_histories-1.0.2-py3-none-any.whl
| Download URL | django_histories-1.0.2-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c70e4b34df95e4cca073e3d9b9ca52a108ddaf8fb8ff50370c66c4849793bcda
|
|
BLAKE2b-256 checksum How to use checksums |
aafa6dd2bfc6422051a2b2bed369a9a9a55e4760e871c009dd5d0badfea1ad91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for django-histories 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.