Middleware¶
Shortcuts when using django-reversion in views.
reversion.middleware.RevisionMiddleware¶
Wrap the every request that isn’t GET
, HEAD
or OPTIONS
in a revision block.
The request user will also be added to the revision metadata.
To enable RevisionMiddleware
, add 'reversion.middleware.RevisionMiddleware'
to your MIDDLEWARE_CLASSES
setting. For Django >= 1.10, add it to your MIDDLEWARE
setting.
Warning
This will wrap every request that isn’t GET
, HEAD
or OPTIONS
in a database transaction. For best performance, consider marking individual views instead.
RevisionMiddleware.manage_manually = False
IfTrue
, versions will not be saved when a model’ssave()
method is called. This allows version control to be switched off for a given revision block.
RevisionMiddleware.using = None
The database to save the revision data. The revision block will be wrapped in a transaction using this database. IfNone
, the default database for reversion.models.Revision will be used.
RevisionMiddleware.atomic = True
IfTrue
, the revision block will be wrapped in atransaction.atomic()
.