Skip to content

Commit 33a6e52

Browse files
rudkjobingRoss Mechanic
authored andcommitted
Select related users when displaying history in admin (#496)
* Select related users This is to avoid n+1 queries * make format
1 parent 1f8974c commit 33a6e52

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

simple_history/admin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def history_view(self, request, object_id, extra_context=None):
4848
pk_name = opts.pk.attname
4949
history = getattr(model, model._meta.simple_history_manager_attribute)
5050
object_id = unquote(object_id)
51-
action_list = history.filter(**{pk_name: object_id})
51+
action_list = history.filter(**{pk_name: object_id}).select_related(
52+
"history_user"
53+
)
5254
history_list_display = getattr(self, "history_list_display", [])
5355
# If no history was found, see whether this object even exists.
5456
try:

0 commit comments

Comments
 (0)