Opened 17 years ago
Last modified 4 years ago
#5863 closed
list_display does not allow functions of referenced objects — at Version 5
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | list_display |
Cc: | andy@…, mike.huynh+django@…, Brillgen Developers, hugo@…, zachborboa@… | Triage Stage: | Design decision needed |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | yes |
Description (last modified by )
It is possible to include a model member function in the list_display
Admin property. The same thing is not possible for ForeignKey models; at least not with any of the variations I have tried: foreign.method
, foreign_method
and foreign__method
.
Change History (5)
comment:1 by , 17 years ago
Summary: | list_display does not allow functions of references objects → list_display does not allow functions of referenced objects |
---|
comment:2 by , 17 years ago
comment:3 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
There is no need to support functions on ForeignKey
models. You can encapsulate that in a function on the model.
comment:4 by , 17 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Thanks for the quick reply, which I have implemented for now.
Still, your proposal violates DRY: I have to define the same function on each model that references the foreign model.
comment:5 by , 17 years ago
Description: | modified (diff) |
---|---|
Triage Stage: | Unreviewed → Accepted |
Seems like a reasonable addition to me. Do we even allow doing this for actual fields of a related model? This feature probably needs to be part of newforms-admin or wait until that branch is merged though. It would be helpful if you could attach a simple example, or even try your hand at creating a patch.
Sorry; the third example should have two underline characters between "foreign" and "method".