---
title: "推荐一个基于models的信号机制记录django model数据操作日志"
author: "alargon"
date: "2018-05-08T12:01:03Z"
tags: []
categories: ["编程语言"]
slug: "models-django-model"
draft: false
lastmod: "2018-05-08T11:48:24Z"
id: 2422231
url: "https://alargon.iteye.com/blog/2422231"
---

github地址：<https://github.com/jjkester/django-auditlog>

使用简单，详情请看使用文档

```python
from auditlog.registry import auditlog
from django.db import models

class MyModel(models.Model):
    pass
    # Model definition goes here

auditlog.register(MyModel)
```


<span style="color:red">注意:model的update方法不能记录日志。只有delete,create,save ，update可以用save代替，或者自己写一个方法手动记录日志到日志表，难度高点</span>