Skip to content

Limit choices of an enum #128

@larsrinn

Description

@larsrinn

This is related to #120. The proposed solution there doesn't work for us, though. The selectable values should be returned in the OPTIONS call for the frontend to only show them.

In our usecase it shouldn't be possible to select all values of an Enum on the model, also for the database model. An idea would be to add this as an additional parameter to the model field, e.g.:

enum_field_with_limited_choices = EnumField(
    EnumWithManyChoices,
    max_length=100,
    selectable_choices=[EnumWithManyChoices.Choice1, EnumWithManyChoices.Choice2]
)

I guess this would be trivial to implement. If you agree it's useful, I can make a proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions