From e42bea985df6578c0588a24ccc61b87ecfcb7fe9 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Tue, 24 Sep 2024 16:09:47 +0800 Subject: [PATCH] Add timestamp filtering for search results in django admin --- backend/search_results/admin.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/search_results/admin.py b/backend/search_results/admin.py index 6fc7c5f..fc50b24 100644 --- a/backend/search_results/admin.py +++ b/backend/search_results/admin.py @@ -1,10 +1,18 @@ from unfold.admin import ModelAdmin from django.contrib import admin from .models import SearchResult +from unfold.contrib.filters.admin import RangeDateFilter @admin.register(SearchResult) class SearchResultAdmin(ModelAdmin): model = SearchResult search_fields = ('id', 'title', 'link') - list_display = ['id', 'title'] + list_display = ['id', 'title', 'timestamp'] + + list_filter_submit = True + list_filter = (( + "timestamp", RangeDateFilter + ), ( + "timestamp", RangeDateFilter + ),)