django - Admin filter for groups not worked -
i have created filter admin page, display users in group , not. using django 1.8 there no problem class. after upgrading django, error :
attributeerror @ /admin/main/profile/ can't set attribute
the code :
class profileadminlistfilter(admin.relatedfieldlistfilter):
def __init__(self, *a, **kw): super(profileadminlistfilter, self).__init__(*a, **kw) def has_output(self): return true @property def include_empty_choice(self): return true @property def empty_value_display(self): return "no group" def choices(self, cl): c in super(profileadminlistfilter, self).choices(cl): yield c if self.include_empty_choice: yield { 'selected': bool(self.lookup_val_isnull), 'query_string': cl.get_query_string({ self.lookup_kwarg_isnull: 'true', }, [self.lookup_kwarg]), 'display': self.empty_value_display, } class profileadmin(admin.modeladmin): list_filter = (('user__groups', profileadminlistfilter),)
Comments
Post a Comment