#7625 closed (wontfix)
admin.list_filter should accept methods with boolean property
Reported by: | 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 , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 16 years ago
comment:3 by , 16 years ago
Cc: | added |
---|
comment:4 by , 16 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
comment:5 by , 16 years ago
Cc: | added |
---|
comment:6 by , 16 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:7 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → 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 by , 16 years ago
Resolution: | wontfix |
---|---|
Status: | closed → 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 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → 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.
sorry, found functionality already.