Opened 16 years ago

Last modified 3 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 by Beat Bolli <me+django@…>, 16 years ago

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

comment:2 by Beat Bolli <me+django@…>, 16 years ago

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

comment:3 by Brian Rosner, 16 years ago

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 by me+django@…, 16 years ago

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 by Gary Wilson, 16 years ago

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