Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support django-choices-field in field_verboses #6

Open
replygirl opened this issue Aug 20, 2024 · 1 comment
Open

support django-choices-field in field_verboses #6

replygirl opened this issue Aug 20, 2024 · 1 comment

Comments

@replygirl
Copy link

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
}
@JobDoesburg
Copy link
Owner

If you open a PR I will gladly accept the change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants