17

When you create or modify an object instance in Django's admin, a changelog entry is created. This is really nice for fairly obvious reasons.

However my model's instances created by a normal user outside of the admin interface. No changelog is recorded to note its creation (not a huge issue) but I would like to track edits the user makes.

I also want to show the user this full log (user+admin edits) in the frontend so I need a way to pull the changelog out.

My question: how? Is there a one-line switch I can flick to enable full logging or do I have to dig in and do something on my user's edit form logic?

Oli
  • 235,628
  • 64
  • 220
  • 299
  • 2
    You can use django admin LogEntry model yourself: http://stackoverflow.com/questions/1398051/getting-the-history-of-an-object – Van Gale Feb 25 '10 at 17:27
  • 1
    Or use Marty Alchin's audit trail: http://stackoverflow.com/questions/818823/django-audittrail-vs-reversion – Van Gale Feb 25 '10 at 17:27

1 Answers1

12

django-reversion is an app designed to help with that.

Jay
  • 18,959
  • 11
  • 53
  • 72
Ofri Raviv
  • 24,375
  • 3
  • 55
  • 55
  • I haven't actually used this solution, but can you actually get a changelog from django-reversion? +1 anyway because I think it still might meet Oli's needs. – Van Gale Feb 25 '10 at 17:31
  • This is by far the simplest method. It has amazing and very pythonic methods of binding on to track changes which fit my style perfectly. I'm sure I'll find a way to extract the list of changes! – Oli Feb 26 '10 at 11:33
  • take a look at admin.py history_view – Ofri Raviv Feb 26 '10 at 12:48
  • 2
    django reversion has moved to github: https://github.com/etianen/django-reversion – alex Mar 03 '12 at 20:35
  • @Oli - curious to know if django-reversion worked for you for the use case above since I am looking to do exactly that. – Anupam May 16 '17 at 06:48
  • 1
    @Anupam Yeah it works well enough and we pull out a changelog based on the reversion models. They all make sense. We occasionally have problems with there not being an initial reversion created before or on the first edit... We could probably be more rigorous though in checking though. It's not a priority. – Oli May 16 '17 at 15:46