gavinzheng / django-reporting

Automatically exported from code.google.com/p/django-reporting
0 stars 0 forks source link

Related filter_lists should either be sorted by display value or allow a sort field to be specified #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I had a model with a foreign key to User and I needed to filter by user's
email address:

    list_filter = [
        'user__email',
    ]

The list came out in a random order.

As a workaround I changed line 20 in filterspecs.py:

for val in values:

to:

for val in sorted(values, key=lambda(x): str.lower(x[1])):

This is fine for my use but will override any existing order_by in the
underlying models. A better solution would be to either allow this to be
turned on or off or even better - allow the user to specify the key to sort by.

Original issue reported on code.google.com by andybak on 27 Jan 2010 at 9:41

GoogleCodeExporter commented 9 years ago
That second line of code should read:

for val in sorted(values, key=lambda(x): unicode.lower(x[1])):

Original comment by andybak on 27 Jan 2010 at 9:49