Add timestamp filtering for search results in django admin

This commit is contained in:
Keannu Bernasol 2024-09-24 16:09:47 +08:00
parent 9e2e32fba8
commit e42bea985d

View file

@ -1,10 +1,18 @@
from unfold.admin import ModelAdmin from unfold.admin import ModelAdmin
from django.contrib import admin from django.contrib import admin
from .models import SearchResult from .models import SearchResult
from unfold.contrib.filters.admin import RangeDateFilter
@admin.register(SearchResult) @admin.register(SearchResult)
class SearchResultAdmin(ModelAdmin): class SearchResultAdmin(ModelAdmin):
model = SearchResult model = SearchResult
search_fields = ('id', 'title', 'link') search_fields = ('id', 'title', 'link')
list_display = ['id', 'title'] list_display = ['id', 'title', 'timestamp']
list_filter_submit = True
list_filter = ((
"timestamp", RangeDateFilter
), (
"timestamp", RangeDateFilter
),)