You can add a date based filtering on any date field by setting the
date_hierarchy
.:@admin.register(Hero)
class HeroAdmin(admin.ModelAdmin, ExportCsvMixin):
...
date_hierarchy = 'added_on'
It looks like this:
This can be very costly with a large number of objects. As an alternative, you can subclass
SimpleListFilter
, and allow filtering only on years or the months.
No comments:
Post a Comment