你有没有想过这个?Reversion 通过执行以下操作在内部执行此操作:
def history_view(self, request, object_id, extra_context=None):
"""Renders the history view."""
# check if user has change or add permissions for model
if not self.has_change_permission(request):
raise PermissionDenied
object_id = unquote(object_id) # Underscores in primary key get quoted to "_5F"
opts = self.model._meta
action_list = [
{
"revision": version.revision,
"url": reverse("%s:%s_%s_revision" % (self.admin_site.name, opts.app_label, opts.module_name), args=(quote(version.object_id), version.id)),
}
for version
in self._order_version_queryset(self.revision_manager.get_for_object_reference(
self.model,
object_id,
).select_related("revision__user"))
]
# Compile the context.
context = {"action_list": action_list}
context.update(extra_context or {})
return super(VersionAdmin, self).history_view(request, object_id, context)