Views¶
Shortcuts when using django-reversion in views.
Decorators¶
reversion.views.create_revision(manage_manually=False, using=None, atomic=True, request_creates_revision=None)
Decorates a view to wrap every request in a revision block.
The request user will also be added to the revision metadata. You can set the revision comment by calling reversion.set_comment() within your view.
manage_manually
If
True
, 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.using
The database to save the revision data. The revision block will be wrapped in a transaction using this database. If
None
, the default database for reversion.models.Revision will be used.atomic
If
True
, the revision block will be wrapped in atransaction.atomic()
.
request_creates_revision
Hook used to decide whether a request should be wrapped in a revision block. If
None
, it will default to omittingGET
,HEAD
andOPTIONS
requests.
reversion.views.RevisionMixin¶
Mixin a class-based view to wrap every request in a revision block.
The request user will also be added to the revision metadata. You can set the revision comment by calling reversion.set_comment() within your view.
from django.contrib.auth.views import FormView
from reversion.views import RevisionMixin
class RevisionFormView(RevisionMixin, FormView):
pass
RevisionMixin.revision_manage_manually = False
If
True
, 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.
RevisionMixin.revision_using = None
The database to save the revision data. The revision block will be wrapped in a transaction using this database. If
None
, the default database for reversion.models.Revision will be used.
RevisionMixin.revision_request_creates_revision(request)
By default, any request that isn’t
GET
,HEAD
orOPTIONS
will be wrapped in a revision block. Override this method if you need to apply a custom rule.