这个django应用程序以一种简单和细粒度的方式记录对模型对象的更改。

django-auditor的Python项目详细描述


这个django应用程序在一个简单的 颗粒状的。此应用程序支持多租户环境 使用django租户模式。

要求

python 3.4

Django 1.8

安装(适用于没有django租户架构的环境)

将“auditor”添加到已安装的应用程序设置中,如下所示:

INSTALLED_APPS=(...'django_auditor',)

在您的设置中添加一个空的dict“auditor”:

AUDITOR={}

在项目url.py中包含auditor urlconf,如下所示:

url(r'^auditor/',include('django_auditor.urls'))

运行python manage.py makemigrations创建迁移 审计员模型的文件。

运行python manage.py migrate以应用迁移和 创建审计员模型。

安装(django租户模式环境)

将“auditor”添加到您的共享应用程序或租户应用程序设置中 像这样:

SHARED_APPS=(...'django_auditor',)

TENANT_APPS=(...'django_auditor',)

在设置中添加dict“auditor”,指定“tenant” 键入租户模型的值:

AUDITOR={'tenant':'customers.Client'}

在项目url.py中包含auditor urlconf,如下所示:

url(r'^auditor/',include('django_auditor.urls'))

运行python manage.py makemigrations创建迁移 审计员模型的文件。

运行python manage.py migrate_schemas以应用迁移和 创建审计员模型。

用法和示例

创建审核传递请求的实例和所需的对象 要记录,请调用方法create()、update()或delete() 使用适当的操作生成日志:创建、更新或 删除。

首先必须导入审核类:

fromdjango_auditor.auditorimportAudit

新对象

new_car=Car(name='Civic',manufacturer='Honda',color='Red')new_car.save()auditor=Audit(request,new_car).create()

Example Create

更新对象

change_car=Car.objects.get(name='Civic')auditor=Audit(request,change_car)change_car.name='City'change_car.color='Yellow'change_car.save()auditor.update()

Example Update

删除对象

remove_car=Car.objects.get(name='City')auditor=Audit(request,remove_car)remove_car.delete()auditor.delete()

Example Delete

现在打开http://yoursiteURL/auditor检查日志。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
c#Java Tcp服务器和。Net Tcp客户端的发送和接收问题   安卓应用程序上的java标记地理位置,其位置位于我周围5Km半径范围内。   向java添加对话框并检索html文件   当eclipse甚至无法打开时,java会在eclipse中更改不兼容的JVM   java中同一jframe中的jlabel和paintComponent   基于另一数组排序的java排序   java AADSTS7000012:该补助金是为另一个租户获得的   java在JSF中使用foreach循环   java如何通过maven为运行junit测试创建运行配置?   java Selenium webDriver不稳定错误堆栈跟踪   java有没有办法创建以键为大写的JSON对象?