this is my get_list_filter method in user admin
def get_list_filter(self, request):
list_filter = self.list_filter
if request.user.is_superuser:
list_filter.append('is_superuser')
return list_filter
the problem is after each time i call user admin panel in browser, an new is_superuser field wil be add to list filter.
just like this:
first time: list_filter = [<class 'octopus.accounts.admin.user.UserInfoSearch'>, <class 'octopus.accounts.admin.user.UserEmailSearch'>, 'is_staff', 'groups', <class 'octopus.accounts.admin.user.UserRoleStatusFilter'>, <class 'octopus.accounts.admin.reward.UserBuildingFilter'>, <class 'octopus.accounts.admin.user.WorkmanStateFilter'>, 'is_superuser']
second time: list_filte = [<class 'octopus.accounts.admin.user.UserInfoSearch'>, <class 'octopus.accounts.admin.user.UserEmailSearch'>, 'is_staff', 'groups', <class 'octopus.accounts.admin.user.UserRoleStatusFilter'>, <class 'octopus.accounts.admin.reward.UserBuildingFilter'>, <class 'octopus.accounts.admin.user.WorkmanStateFilter'>, 'is_superuser', 'is_superuser']
third time: list_filte = [<class 'octopus.accounts.admin.user.UserInfoSearch'>, <class 'octopus.accounts.admin.user.UserEmailSearch'>, 'is_staff', 'groups', <class 'octopus.accounts.admin.user.UserRoleStatusFilter'>, <class 'octopus.accounts.admin.reward.UserBuildingFilter'>, <class 'octopus.accounts.admin.user.WorkmanStateFilter'>, 'is_superuser', 'is_superuser', 'is_superuser']
as you see is_superuser is added each time!