Document search order for list_display
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)
Easy pickings: |
set
|
Triage Stage: |
Unreviewed → Accepted
|
Type: |
Uncategorized → Cleanup/optimization
|
Cc: |
kobuz added
|
Keywords: |
nlsprint14 added
|
Owner: |
changed from nobody to kobuz
|
Status: |
new → assigned
|
Version: |
1.5 → master
|
Cc: |
eromijn@… added
|
Has patch: |
set
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
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