Browse Source

Corrigido ordenação de AlphabeticFilterSpec.

0.2
Guilherme Gondim 17 years ago
parent
commit
f520e791a6
  1. 5
      sigi/admin/filterspecs.py

5
sigi/admin/filterspecs.py

@ -18,9 +18,10 @@ class AlphabeticFilterSpec(ChoicesFilterSpec):
model_admin) model_admin)
self.lookup_kwarg = '%s__istartswith' % f.name self.lookup_kwarg = '%s__istartswith' % f.name
self.lookup_val = request.GET.get(self.lookup_kwarg, None) self.lookup_val = request.GET.get(self.lookup_kwarg, None)
values_list = model.objects.values_list(f.name, flat=True).order_by(f.name) values_list = model.objects.values_list(f.name, flat=True)
# getting the first char of values # getting the first char of values
self.lookup_choices = set(val[0] for val in values_list) self.lookup_choices = list(set(val[0] for val in values_list))
self.lookup_choices.sort()
def choices(self, cl): def choices(self, cl):
yield {'selected': self.lookup_val is None, yield {'selected': self.lookup_val is None,

Loading…
Cancel
Save