Hide keyboard shortcuts

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-------- 

4 

5The history app is an implementation of ``superdjango.db.history``, providing a concrete history with the option to 

6also record field changes. 

7 

8Install 

9------- 

10 

11Add ``superdjango.contrib.history.apps.DefaultConfig`` to ``INSTALLED_APPS``. 

12 

13Usage 

14----- 

15 

16Integrating History With SuperDjango UI 

17....................................... 

18 

19Specify the history call back for your model UI. 

20 

21.. code-block:: python 

22 

23 from superdjango import ui 

24 from superdjango.contrib.history.models import History 

25 from .models import Project 

26 

27 class ProjectUI(ui.ModelUI): 

28 model = Project 

29 history_callback = History.log 

30 

31 # ... 

32 

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. 

35 

36Integrating History with a Custom View 

37....................................... 

38 

39In this example, we had audit history to an update view: 

40 

41.. code-block:: python 

42 

43 # myapp/views.py 

44 from superdjango.contrib.history.models import History 

45 from superdjango.db.history.utils import get_field_changes 

46 

47 class UpdateTodo(UpdateView): 

48 ... 

49 

50 def form_valid(self, form): 

51 self.object = form.save() 

52 

53 field_changes = get_field_changes(form, self.model, record=self.object) 

54 

55 History.log(self.object, self.request.user, History.UPDATE, fields=field_changes) 

56 

57 ... 

58 

59""" 

60__author__ = "Shawn Davis <shawn@superdjango.com>" 

61__maintainer__ = "Shawn Davis <shawn@superdjango.com>" 

62__version__ = "0.3.0-x"