I was looking for a way to revert data deleted by mistake from the Django admin.
I reverse-engineered how Django's admin builds the list of objects displayed on the "Are you sure?" confirmation page.
Given a single obj
or list of objs
, the script included in this gist will:
- Use the
NestedObjects
utility to determine the objects that would be deleted - Pass those objects to Django's JSON serializer
- Write the objects to a
deleted-objects
fixture