Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Abstract
3--------
5The history app is an implementation of ``superdjango.db.history``, providing a concrete history with the option to
6also record field changes.
8Install
9-------
11Add ``superdjango.contrib.history.apps.DefaultConfig`` to ``INSTALLED_APPS``.
13Usage
14-----
16Integrating History With SuperDjango UI
17.......................................
19Specify the history call back for your model UI.
21.. code-block:: python
23 from superdjango import ui
24 from superdjango.contrib.history.models import History
25 from .models import Project
27 class ProjectUI(ui.ModelUI):
28 model = Project
29 history_callback = History.log
31 # ...
33You'll also need to add the :py:class:`superdjango.contrib.history.ui.HistoryUI` to a menu that is registered in order
34to access history records.
36Integrating History with a Custom View
37.......................................
39In this example, we had audit history to an update view:
41.. code-block:: python
43 # myapp/views.py
44 from superdjango.contrib.history.models import History
45 from superdjango.db.history.utils import get_field_changes
47 class UpdateTodo(UpdateView):
48 ...
50 def form_valid(self, form):
51 self.object = form.save()
53 field_changes = get_field_changes(form, self.model, record=self.object)
55 History.log(self.object, self.request.user, History.UPDATE, fields=field_changes)
57 ...
59"""
60__author__ = "Shawn Davis <shawn@superdjango.com>"
61__maintainer__ = "Shawn Davis <shawn@superdjango.com>"
62__version__ = "0.3.0-x"