Skip to content

support django-choices-field in field_verboses #6

@replygirl

Description

@replygirl

using bellini666/django-choices-field, i have an integer field defined like:

class FooRole(models.IntegerChoices):
  FOO = 0, "Foo"
  BAR = 1, "Bar"
  BAZ = 2, "Baz"
  QUX = 3, "Qux"

class FooModel(models.Model)
  role = IntegerChoicesField(
    choices_enum=WorkspaceUserRole, default=FooRole.FOO
  )

...which when used with MultiSelectFieldListFilter looks like:

Screenshot 2024-08-20 at 5 59 17 PM

i think the labels from the fields in django-choices-field could be used if this lookup on self.field.choices could fall back to self.field.choices_enum.choices:

self.field_verboses = {
  field_value: field_verbose
  for field_value, field_verbose in self.field.choices
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions