Opened 15 years ago

Last modified 2 years ago

#5863 closed

list_display does not allow functions of referenced objects — at Version 5

Reported by: Beat Bolli <me+django@…> 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 Gary Wilson)

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 Changed 15 years ago by Beat Bolli <me+django@…>

Summary: list_display does not allow functions of references objectslist_display does not allow functions of referenced objects

comment:2 Changed 15 years ago by Beat Bolli <me+django@…>

Sorry; the third example should have two underline characters between "foreign" and "method".

comment:3 Changed 15 years ago by Brian Rosner

Resolution: invalid
Status: newclosed

There is no need to support functions on ForeignKey models. You can encapsulate that in a function on the model.

comment:4 Changed 15 years ago by me+django@…

Resolution: invalid
Status: closedreopened

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 Changed 15 years ago by Gary Wilson

Description: modified (diff)
Triage Stage: UnreviewedAccepted

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.

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