summaryrefslogtreecommitdiff
path: root/django-simple-history/simple_history/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'django-simple-history/simple_history/__init__.py')
-rwxr-xr-xdjango-simple-history/simple_history/__init__.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/django-simple-history/simple_history/__init__.py b/django-simple-history/simple_history/__init__.py
new file mode 100755
index 000000000..6df0b60b6
--- /dev/null
+++ b/django-simple-history/simple_history/__init__.py
@@ -0,0 +1,22 @@
+import models
+
+
+registered_models = {}
+
+
+def register(model, app=None, manager_name='history'):
+ """
+ Create historical model for `model` and attach history manager to `model`.
+
+ Keyword arguments:
+ app -- App to install historical model into (defaults to model.__module__)
+ manager_name -- class attribute name to use for historical manager
+
+ This method should be used as an alternative to attaching an
+ `HistoricalManager` instance directly to `model`.
+ """
+ if not model in registered_models:
+ records = models.HistoricalRecords()
+ records.manager_name = manager_name
+ records.module = ("%s.models" % app) or model.__module__
+ records.finalize(model)