Code

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#7625 closed (wontfix)

admin.list_filter should accept methods with boolean property

Reported by: ashley@… Owned by: nobody
Component: contrib.admin Version: master
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: UI/UX:

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.

Attachments (0)

Change History (10)

comment:1 Changed 6 years ago by Ashley Camba <ashwoods@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

comment:2 Changed 6 years ago by Ashley Camba <ashwoods@…>

sorry, found functionality already.

comment:3 Changed 6 years ago by anonymous

  • Cc metzen@… added

comment:4 Changed 6 years ago by ashley camba <stuff4ash@…>

  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:5 Changed 6 years ago by anonymous

  • Cc mbonetti@… added

comment:6 Changed 6 years ago by ericholscher

  • Triage Stage changed from Unreviewed to Design decision needed

comment:7 Changed 6 years ago by simon

  • Resolution set to wontfix
  • Status changed from reopened to closed

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 Changed 6 years ago by ashley camba <stuff4ash@…>

  • Resolution wontfix deleted
  • Status changed from closed to reopened

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 Changed 6 years ago by brosner

  • Resolution set to wontfix
  • Status changed from reopened to closed

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 Changed 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.