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

Use JSONField for object repr field #298

Open sgordon16 opened 1 month ago

sgordon16 commented 1 month ago

Is there any reason why we can't use JSONField instead of TextField for object_json_repr? It would allow for querying within the json for specific logs.

https://docs.djangoproject.com/en/5.0/ref/models/fields/#jsonfield

jheld commented 1 month ago

I guess we probably can since django 3.1 was the first version to include universal JSON support on all supported db backends. Before that, we couldn't. Open to creating a PR?

sgordon16 commented 1 month ago

PR #299

sgordon16 commented 1 month ago

Side question. Is there a reason why object_json_repr is stored in a list? It's a bit un-intuitive to have to add the 0 to query the json. CRUDEvent.objects.filter(object_json_repr__0__model="app.model") https://github.com/soynatan/django-easy-audit/blob/70e192ba7cb527c0b4bc1c02022ea045fd2829eb/easyaudit/signals/model_signals.py#L90