Possible to turn on by default on all admin
Closed this issue · 1 comments
zehawki commented
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).
silentsokolov commented
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)