0

I want to record the user in a database who created, updated or deleted an object there using django. I've found a simple solution with threadlocal and a logging abstract class from here : Why is using thread locals in Django bad? ( but that is discouraged ).

But the problem with this solution is that it is extremely difficult to write any unit test. So what would be a better solution for logging event based information about a user who created, updated, or deleted an object in django?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335

1 Answers1

1

You can try django-simple-history. (https://django-simple-history.readthedocs.io/en/latest/querying_history.html)

It provides an history in django admin or querying history from python code

Eric Martin
  • 501
  • 4
  • 10
  • This solves most of the problem, though each time user that manipulates the object must be assigned manually. The package keeps all the history which is really useful. Thanks a lot, I cannot find anything better than this. – Bivek Chalise Aug 23 '20 at 17:29