Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#21902 closed Cleanup/optimization (fixed)

Document search order for list_display

Reported by: schrinaw@… Owned by: kobuz
Component: Documentation Version: dev
Severity: Normal Keywords: admin nlsprint14
Cc: kobuz, eromijn@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Suppose I have a ModelAdmin with list_display = ["some","model","fields"] but then I also want to override how one of those fields is displayed, so I create a method on the ModelAdmin Class

def some(self, obj):
    return "blah"

It seems the model field takes precedence over the method on the ModelAdmin, and I don't see "blah" returned in the changelist. This is not clear from the documentation. (I figured I would be able to override it).

On a related note, I think it makes sense to be able to override it in the ModelAdmin.

Change History (7)

comment:1 by Baptiste Mispelon, 10 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

Hi,

As described in the documentation [1], you can pass four different kinds of values for list_display.

However, what that section doesn't say is that the given list is actually the order in which Django tries each possibility.

I agree that it'd be useful to amend the documentation to mention explicitly that the order of the list is the one Django uses.

As for the feature you're proposing, I don't see much value in it, for two reasons:
1) It's already possible to override a field's display by defining a method on the ModelAdmin you just need to give it a different name
2) Backwards-compatibility would be tricky

So I'm marking this ticket as accepted for the documentation issue (which should be fairly trivial to fix), but I'm -0 on the proposed change.

Thanks.

[1] https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display

comment:2 by Aymeric Augustin, 10 years ago

Type: UncategorizedCleanup/optimization

comment:3 by kobuz, 10 years ago

Cc: kobuz added
Keywords: nlsprint14 added
Owner: changed from nobody to kobuz
Status: newassigned
Version: 1.5master

comment:5 by Sasha Romijn, 10 years ago

Cc: eromijn@… added
Has patch: set
Triage Stage: AcceptedReady for checkin

Patch looks good to me :)

comment:6 by Baptiste Mispelon <bmispelon@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 09b725f51bbfa0f01b27ee2d718889926d409519:

Fixed #21902 -- Documented search order for list_display.

comment:7 by Baptiste Mispelon <bmispelon@…>, 10 years ago

In 98070b94a9bbb8e915e724c4d23933bd3b243b3c:

[1.6.x] Fixed #21902 -- Documented search order for list_display.

Backport of 09b725f51bbfa0f01b27ee2d718889926d409519 from master.

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