soynatan / django-easy-audit

Yet another Django audit log app, hopefully the simplest one.
GNU General Public License v3.0
719 stars 178 forks source link

Upgrade `EasyAuditMiddleware` to support sync and async contexts. #291

Open KaczuH opened 4 months ago

KaczuH commented 4 months ago

EasyAuditMiddleware currently only supports synchronous code, requiring adaptations by Django for async operation.

As such, projects using easy audit cannot benefit from async stack as shown by the django.request logger:

DEBUG:django.request:Asynchronous handler adapted for middleware easyaudit.middleware.easyaudit.EasyAuditMiddleware.

Relevant Django documentation can be found in Django Docs:.

There is a potential simple fix: replacing threading.local with asgiref and using MiddlewareMixin.