mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2024-11-17 04:09:25 +08:00
Add timestamp filtering for search results in django admin
This commit is contained in:
parent
9e2e32fba8
commit
e42bea985d
1 changed files with 9 additions and 1 deletions
|
@ -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
|
||||||
|
),)
|
||||||
|
|
Loading…
Reference in a new issue