Skip to content

Commit 3f38d97

Browse files
snps-msilvamjsir911
authored andcommitted
POC for #72
Note that if you are using any custom methods on the model for the admin display, you need to use a History Base class for this to work(#311).
1 parent b5eadd5 commit 3f38d97

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

simple_history/admin.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,18 @@ def enforce_history_permissions(self):
284284
return getattr(
285285
settings, "SIMPLE_HISTORY_ENFORCE_HISTORY_MODEL_PERMISSIONS", False
286286
)
287+
288+
289+
class SimpleHistoryShowDeletedFilter(admin.SimpleListFilter):
290+
title = "Entries"
291+
parameter_name = "entries"
292+
293+
def lookups(self, request, model_admin):
294+
return (
295+
("deleted_only", "Only Deleted"),
296+
)
297+
298+
def queryset(self, request, queryset):
299+
if self.value():
300+
return queryset.model.history.filter(history_type='-').distinct()
301+
return queryset

0 commit comments

Comments
 (0)