Django Undo Feature - Creating a single list of actions to undo changes in multiple models

I'm starting to add an "undo" feature to a Django Web App, and I'm not sure the best approach.

I looked at some of the revisioning packages like django-simple-history but ran into issues:

  1. not all of them handle bulk_update and similar methods, and

  2. since the modals are all linked and an update here triggers a bulk-update there and delete loop there, the simplest approach seems to be undo-ing one step at a time. The packages I've found want to handle each model separately without an app-wide chronological list, so to properly roll back a change I need to query every history record and sort them by date, then roll back everything until I hit the desired position.

This seems to be problematic, I feel like I'll run into issues with things being out of order, or simple speed issues while pulling the last 100 records for every historical object and merging/sorting them together into a chronological list.

I'm leaning towards - making an audit log of every change app-wide, marking items for deletion instead of deleting them, etc., and pretty much rolling my own system.

Am I falling victim to "not invented here"? Is there a simple process I'm missing?

Appreciate the help

Вернуться на верх