18
18
from django .utils .encoding import force_text
19
19
except ImportError : # django 1.3 compatibility
20
20
from django .utils .encoding import force_unicode as force_text
21
+ from django .conf import settings
22
+
23
+ try :
24
+ USER_NATURAL_KEY = settings .AUTH_USER_MODEL
25
+ except AttributeError :
26
+ USER_NATURAL_KEY = "auth.User"
27
+ USER_NATURAL_KEY = tuple (key .lower () for key in USER_NATURAL_KEY .split ('.' , 1 ))
21
28
22
29
23
30
class SimpleHistoryAdmin (admin .ModelAdmin ):
@@ -52,6 +59,10 @@ def history_view(self, request, object_id, extra_context=None):
52
59
action_list = history .filter (** {pk_name : object_id })
53
60
# If no history was found, see whether this object even exists.
54
61
obj = get_object_or_404 (model , pk = object_id )
62
+ content_type = ContentType .objects .get_by_natural_key (
63
+ * USER_NATURAL_KEY )
64
+ admin_user_view = 'admin:%s_%s_change' % (content_type .app_label ,
65
+ content_type .model )
55
66
context = {
56
67
'title' : _ ('Change history: %s' ) % force_text (obj ),
57
68
'action_list' : action_list ,
@@ -60,6 +71,7 @@ def history_view(self, request, object_id, extra_context=None):
60
71
'root_path' : getattr (self .admin_site , 'root_path' , None ),
61
72
'app_label' : app_label ,
62
73
'opts' : opts ,
74
+ 'admin_user_view' : admin_user_view
63
75
}
64
76
context .update (extra_context or {})
65
77
return render (request , template_name = self .object_history_template ,
0 commit comments