João Pedro Francese committed 0b8291c Draft

Fix the history admin to work when the manager attribute in the model is not named 'history'.

Comments (0)

Files changed (3)

             data_files.append(os.path.join(prefix, f))
-      version='1.1.2',
+      version='1.1.3',
       description='Store Django model history with the ability to revert back to a specific change at any time.',
       author='Corey Bertram',


         opts = model._meta
         app_label = opts.app_label
         pk_name =
-        action_list = model.history.filter(**{pk_name: object_id})
+        history = getattr(model, model._meta.simple_history_manager_attribute)
+        action_list = history.filter(**{pk_name: object_id})
         # If no history was found, see whether this object even exists.
         obj = get_object_or_404(model, pk=unquote(object_id))
         context = {
     def history_form_view(self, request, object_id, version_id):
         original_model = self.model
         original_opts = original_model._meta
-        model = self.model.history.model
+        history = getattr(self.model, self.model._meta.simple_history_manager_attribute)
+        model = history.model
         opts = model._meta
         app_label = opts.app_label
         pk_name =


         descriptor = HistoryDescriptor(history_model)
         setattr(sender, self.manager_name, descriptor)
+        sender._meta.simple_history_manager_attribute = self.manager_name
     def create_history_model(self, model):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.