Closed zehawki closed 1 year ago
You can override __init__
method of ModelAdmin
and add something like this:
def __init__(self, *arg, **kwarg):
super().__init__(self, *arg, **kwarg)
fields = ['created_at', 'modified_at']
def _default_range(self, request)
return 0
for f in fields:
setattr(self.__class__, f'get_rangefilter_{f}_default', _default_range)
Adding this to each admin field one by one is cumbersome... Is there some way to add by default for fields that are present in all models, eg created_at, modified_at (in my case).