Opened 16 years ago

Closed 16 years ago

#7724 closed (invalid)

get_FIELD_display in backend doesn't respect FIELD's name or verbose_name

Reported by: CaptainCapacitor Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords: admin, get_FIELD_*, name, verbose name
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

colour_choices = [(0, 'red'), (1, 'blue'), (2, 'green')]

class Car(models.Model):
    ...
    colour = models.IntegerField(name='colour', verbose_name='Primary Colour', choices=colour_choices)
    ...

    class Admin:
        list_display=['name', 'year', 'make', 'model', 'get_colour_display']

In the Admin panel, the final field is titled "Get Colour Display", and no amount of effort can convince it otherwise.

Change History (1)

comment:1 by Malcolm Tredinnick, 16 years ago

Resolution: invalid
Status: newclosed

There's nothing to suggest it should behave like this. You're hoping it might, but it isn't really worth the extra code when there's already a way to set the title. When you use a function in the list_display list it uses the short_description attribute on the function for the title, otherwise a reasonable default is used. This is documented and the versions of get_FIELD_display() created automatically are no different int his respect.

Note: See TracTickets for help on using tickets.
Back to Top