django-reversion can be used to add a powerful rollback and recovery facility to your admin site. To enable this, simply register your models with a subclass of reversion.VersionAdmin.
import reversion
class YourModelAdmin(reversion.VersionAdmin):
pass
admin.site.register(YourModel, YourModelAdmin)
You can also use reversion.VersionAdmin as a mixin with another specialized admin class.
class YourModelAdmin(reversion.VersionAdmin, YourBaseModelAdmin):
pass
If you’re using an existing third party app, then you can add patch django-reversion into its admin class by using the reversion.helpers.patch_admin() method. For example, to add version control to the built-in User model:
from reversion.helpers import patch_admin
patch_admin(User)
It’s possible to customize the way django-reversion integrates with your admin site by specifying options on the subclass of reversion.VersionAdmin as follows:
class YourModelAdmin(reversion.VersionAdmin):
option_name = option_value
The available admin options are:
In addition to specifying custom templates using the options above, you can also place specially named templates on your template root to override the default templates on a per-model or per-app basis.
For example, to override the recover_list template for the user model, the auth app, or all registered models, you could create a template with one of the following names: