I've hacked my way into the admin filters, changing the
RelatedFilterSpec from a single-select filter to a multi-select filter.
I can now filter on multiple values from the same ManyToMany or
ForeignKey relationship, i.e. if I add 'groups' to the list_filter for
Users, I can select all users that fall into the Admin or the Editor
group (or both, or more).
Would this be a useful replacement for the current version, or could it
become an addition to the current filter methods?
I plan to do some more work on it (basically, a specifier to indicate
if you want OR or AND for your multiple selection, it is now OR only
(and AND will only work for ManyToMany of course)).
Should I create a ticket for this and attach a patch?
Ciao, Marc.
(I posted a similar message on Django users yesterday but I think it is
more appropriate here)
- i can think of using that functionality
- AND would be important for me
- don´t know if a ticket is appropriate (see: http://
code.djangoproject.com/changeset/2830)
patrick
Screenshots for and/or will make it clear what this patch does :-)
http://www.million.nl/file/marc/django/multi-select-relatedfilterspec-and.gif
http://www.million.nl/file/marc/django/multi-select-relatedfilterspec-or.gif
Known bugs:
If there are no results, e.g. when combined with one of the other
filters, all filters revert back to 'All'. This is probably some
exception somewhere that I will track down soon
Unknown bugs:
I have to find out what happens when there is more than one
RelatedFilterSpec set for the admin-view.
More later!
Ciao, Marc.
This also solves the recordcount mismatch in the results view.
On a side note: if you have trouble with hidden Exceptions (as I had in
this case), it really helps if you change the lines (603+604 in
contrib.admin.views.main) from
except:
raise IncorrectLookupParameters
temporarily into
except:
raise
Ciao, Marc.
>
> Update: the known bug is solved, the complete patch is now:
> http://www.million.nl/file/marc/django/multi-select-
> relatedfilterspec.2.diff
Though I can't currently use admin pages at all, this looks cute. Why
don't you open a ticket and provide it as a patch? Even if it is
rejected, it's much easier to find useful patches this way.
Michael
Ciao, Marc.