Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#7625 closed (wontfix)

admin.list_filter should accept methods with boolean property

Reported by: ashley@… Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords:
Cc: metzen@…, mbonetti@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Example:

I have a model with a start_time, end_time.
And a method that does something like this:

def overnight(self):

if self.end:

if self.start.day < self.end.day:

return True

else:

return False

overnight.boolean = True

It would be nice to be able to add overnight to list_filters, at least if boolean property set.

Change History (10)

comment:1 by Ashley Camba <ashwoods@…>, 16 years ago

Resolution: invalid
Status: newclosed

comment:2 by Ashley Camba <ashwoods@…>, 16 years ago

sorry, found functionality already.

comment:3 by anonymous, 16 years ago

Cc: metzen@… added

comment:4 by ashley camba <stuff4ash@…>, 16 years ago

Resolution: invalid
Status: closedreopened

comment:5 by anonymous, 16 years ago

Cc: mbonetti@… added

comment:6 by Eric Holscher, 16 years ago

Triage Stage: UnreviewedDesign decision needed

comment:7 by simon, 16 years ago

Resolution: wontfix
Status: reopenedclosed

I'm marking this as wontfix, because Django's filters work by generating SQL queries using the ORM - filtering on the return value of a function can't be translated in to a SQL query, so implementing this would require loading EVERY row in to the ORM and calling the function on every single one of them. This is too inefficient.

comment:8 by ashley camba <stuff4ash@…>, 16 years ago

Resolution: wontfix
Status: closedreopened

One posibility would be then a shortcut to be able to define filters with functions that return a queryset, and be able to add them to "list_filters".

comment:9 by Brian Rosner, 16 years ago

Resolution: wontfix
Status: reopenedclosed

Please don't reopen wontfixed tickets without discussion on the django-developers mailing list. The functionality described in this ticket is just not going to work due to reasonings Simon provided. There is already a ticket, #5833, that will provide a much more flexible list_filter in the future.

comment:10 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top