jazzband / django-auditlog

A Django app that keeps a log of changes made to an object.
MIT License
1.11k stars 408 forks source link

LogEntry.changes_str fails with KeyError when using m2m_fields #585

Open moises-perez-tfs opened 10 months ago

moises-perez-tfs commented 10 months ago

LogEntry.changes_str is not able to handle the dictionary obtained when using Many-to-Many (m2m) fields. It expects the values part to always be a list. When using m2m fields values is a dictionary in the form of {'type': 'm2m', 'operation': 'some_action', 'objects': [...]}.

The error raised is an KeyError when trying to access values[0] in line https://github.com/jazzband/django-auditlog/blob/9e987169da37930092417c35f5a7ae1ae11ca623/auditlog/models.py#L416C21-L416C30

hramezani commented 10 months ago

Thanks @moises-perez-tfs for reporting this.

We are preparing auditlog for V3 major release. and it's in beta.

Could you please try to install django-auditlog from master branch and see if you can reproduce the problem in master?

Also, it would be great if you provide more information like a failing test.