On Fri, 2006-08-11 at 04:48 -0700, Bjørn Stabell wrote: > Hi, > > Is there any way to add fields to the django admin list view so that > they are: > > * displayed > * sortable > * filterable > > I know it's possible to create custom methods on the model that you can > have displayed in the list view, but I haven't found any way to make > them sortable or filterable. > > I tried adding an custom manager and overriding the query set by adding > an extra=() method (that does add more fields to the query), but the > admin seems to relate everything back to fields in the model when it > comes to sorting and filtering. :(
Sorting and filtering happen at the database level, so you definitely need to be looking at around that level. If you are really desperate to do filering have a look at contrib/admin/filterspecs.py and rummage around to see how they are used. It is possible to create and register your own ones (although entirely undocumented). I suspect sorting is much harder. Have a look at how the current stuff is implemented in contrib/admin/templatetags/admin_list.py (the result_headers() method, in particular), if you want to try and customise that. However, a quick look doesn't reveal any easy hooks to latch onto. Regards, Malcolm > > Is there any way? > > Rgds, > Bjorn > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---