iommirocks / iommi

Your first pick for a django power cord
http://iommi.rocks
BSD 3-Clause "New" or "Revised" License
784 stars 51 forks source link

CharField with choices not well supported (probably also numeric fields with choices) #407

Closed berycz closed 1 month ago

berycz commented 1 year ago

When I have model fields as CharField with choices and I use auto__model

  1. in the filter form I get text-input instead of select2, then I have to define
    query__form__fields__foo = Field.choice(choices=[...], choice_display_name_formatter=lambda choice, **_: ...)
  2. in the table columns I get raw values instead of the "display names", then I have to define
    columns__foo__cell__value = lambda row, **_: ...

would be nice to get that out of the box :)

berycz commented 1 year ago

I may be wrong, the 1. seems to actually work now, but the 2. not for some reason

leethobbit commented 1 month ago

Going to add a comment here as this seems to be the same issue and I was asked to open an issue by boxed.

ISSUE: When using auto__model to display fields in a Table or Form, and that field is a choice field, it should display the human readable or "display values" by default. Instead, it is displaying the actual value.

I am noticing this specifically with CharField - I do not current do choices with any other field type.

Link to relevant Django docs: https://docs.djangoproject.com/en/5.1/ref/models/fields/#choices

Thank you!