django-datalogger 无侵入记录 model 数据变更

smalllion 发布于3月前 阅读2679次
0 条评论

Datalogger

Datalogger is a simple Django app to record data changes.

中文说明

Quick start

  • Installation.
pip install django-datalogger
  • Add django-datalogger to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
        ...
        'django-datalogger',
    ]
  • Add datalogger.middleware.common.DataUpadataDeleteMiddleware to your MIDDLEWARE_CLASSES setting like this::
MIDDLEWARE_CLASSES = (
    ...
    'datalogger.middleware.common.DataUpadataDeleteMiddleware',
    )
  • Run python manage.py makemigrations and python manage.py migrate to create the django-datalogger models.

  • Start your models inherit LogOnUpdateDeleteModel abstract model like this:

class TestA(LogOnUpdateDeleteModel):
    name = models.CharField( max_length=128, blank=True)
    memo = models.TextField()
    create_at = models.DateTimeField(blank=True, auto_now_add=True)
    update_at = models.DateTimeField(blank=True, auto_now=True)
  • Change the test model data by the model api.

  • You will find the data change log in datalogger models.You can visit http://127.0.0.1:8000/admin/ to see these changer.

Reference

查看原文: django-datalogger 无侵入记录 model 数据变更

共收到0条回复

需要 登录 后回复方可回复, 如果你还没有账号你可以 注册 一个帐号。