File: views.rst

package info (click to toggle)
django-reversion 5.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 868 kB
  • sloc: python: 2,631; makefile: 22; sh: 7; sql: 1
file content (53 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
.. _views:

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 :ref:`reversion.set_comment() <set_comment>` within your view.

    .. include:: /_include/create-revision-args.rst

    ``request_creates_revision``

        Hook used to decide whether a request should be wrapped in a revision block. If ``None``, it will default to omitting ``GET``, ``HEAD`` and ``OPTIONS`` 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 :ref:`reversion.set_comment() <set_comment>` within your view.

.. code:: python

    from django.contrib.auth.views import FormView
    from reversion.views import RevisionMixin

    class RevisionFormView(RevisionMixin, FormView):

        pass


``RevisionMixin.revision_manage_manually = False``

    .. include:: /_include/create-revision-manage-manually.rst


``RevisionMixin.revision_using = None``

    .. include:: /_include/create-revision-using.rst

``RevisionMixin.revision_request_creates_revision(request)``

    By default, any request that isn't ``GET``, ``HEAD`` or ``OPTIONS`` will be wrapped in a revision block. Override this method if you need to apply a custom rule.