Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#21902 closed Cleanup/optimization (fixed)

Document search order for list_display

Reported by: schrinaw@… Owned by: kobuz
Component: Documentation Version: master
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


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 Changed 22 months ago by bmispelon

  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted


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.



comment:2 Changed 22 months ago by aaugustin

  • Type changed from Uncategorized to Cleanup/optimization

comment:3 Changed 22 months ago by kobuz

  • Cc kobuz added
  • Keywords nlsprint14 added
  • Owner changed from nobody to kobuz
  • Status changed from new to assigned
  • Version changed from 1.5 to master

comment:5 Changed 22 months ago by erikr

  • Cc eromijn@… added
  • Has patch set
  • Triage Stage changed from Accepted to Ready for checkin

Patch looks good to me :)

comment:6 Changed 22 months ago by Baptiste Mispelon <bmispelon@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 09b725f51bbfa0f01b27ee2d718889926d409519:

Fixed #21902 -- Documented search order for list_display.

comment:7 Changed 22 months ago by Baptiste Mispelon <bmispelon@…>

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