How to define custom labels for admin.ModelAdmin readonly fields.

37 views
Skip to first unread message

Jonty Needham

unread,
Jan 11, 2016, 11:22:37 AM1/11/16
to django...@googlegroups.com
I have a ModelAdmin class where I am using callables to define accessors to a foreign key's field.

I.e.

class MyAdmin(admin.ModelAdmin):

    def field_name(self, obj):
        return obj.fk.field_name

    readonly_fields=(field_name, other_field)


Ultimately I need to translate the labels, but I need access to them first and I can't see from the ModelAdmin code where that is.

Erik Cederstrand

unread,
Jan 11, 2016, 12:45:10 PM1/11/16
to Django Users
It sounds like you're looking for the 'short_description' option described in https://docs.djangoproject.com/en/1.9/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display

Erik

Jonty Needham

unread,
Jan 11, 2016, 5:55:14 PM1/11/16
to django...@googlegroups.com
Thanks so much. Sorted competely!


Erik

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9E3DD769-26A9-4DD5-A1D7-08327ECB5358%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages