Opened 18 years ago
Closed 18 years ago
#2334 closed defect (invalid)
Warning raised when list_filter contains a model method name
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Core (Other) | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The Admin list_display
property for one of my models contains a method name together with a few field names. Everything works ok, but the manage.py
script displays the following warning:
Validating models... journals.article: "admin.list_filter" refers to 'get_short_title', which isn't a field. 1 error found.
A simple patch to management.py makes the warning go away, but I have no idea about possible side-effects:
Index: core/management.py =================================================================== --- core/management.py (revisione 3336) +++ core/management.py (copia locale) @@ -946,7 +946,8 @@ try: f = opts.get_field(fn) except models.FieldDoesNotExist: - e.add(opts, '"admin.list_filter" refers to %r, which isn\'t a field.' % fn) + if not callable(getattr(cls, fn)): + e.add(opts, '"admin.list_filter" refers to %r, which isn\'t a field.' % fn) if fn not in opts.admin.list_display: e.add(opts, '"admin.list_display_links" refers to %r, which is not defined in "admin.list_display".' % fn) # list_filter
Change History (2)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
This behavior is correct. list_filter
doesn't accept method names.
Note:
See TracTickets
for help on using tickets.
Grrr, the patch should be