#21902 closed Cleanup/optimization (fixed)
Document search order for list_display
Reported by: | 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 |
Pull Requests: | |||
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 , 11 years ago
Easy pickings: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 11 years ago
Type: | Uncategorized → Cleanup/optimization |
---|
comment:3 by , 11 years ago
Cc: | added |
---|---|
Keywords: | nlsprint14 added |
Owner: | changed from | to
Status: | new → assigned |
Version: | 1.5 → master |
comment:5 by , 11 years ago
Cc: | added |
---|---|
Has patch: | set |
Triage Stage: | Accepted → Ready for checkin |
Patch looks good to me :)
comment:6 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
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 name2) 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