I have overridden the list_display to show inline fields like this:
class opportunityAdmin(admin.ModelAdmin):
list_display = ('name', 'Contact', 'Phone', 'Address', 'discovery_date', 'status' , 'outcome')
search_fields = ['name', 'tags' , 'description']
#readonly_fields = ('discovery_date','close_date')
inlines = [account_contactInline, account_updateInline]
def Contact(self, obj):
return '<br/>'.join(c.account_poc for c in account_contact.objects.filter(opportunity=obj.id).order_by('id')[:1])
def Phone(self, obj):
return '<br/>'.join(c.account_phone for c in account_contact.objects.filter(opportunity=obj.id).order_by('id')[:1])
def Address(self, obj):
return '<br/>'.join(c.account_address for c in account_contact.objects.filter(opportunity=obj.id).order_by('id')[:1])
My question is, in Django admin, the display name of the inline fields header used the function name: Contact, Phone and Address respectively. Actually i wanna display those field header with custom text. I even wanna use Chinese to display them. What have i missed?
You would need to define the short_description
attribute on your functions: https://docs.djangoproject.com/en/stable/ref/contrib/admin/actions/#writing-action-functions
For example:
Contact.short_description = 'foo'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With