Skip to content

Incompatibility with django-filter #95

@kmmbvnr

Description

@kmmbvnr

It seems default django-enumfields form field rendering is incompatible with django-filters

class Color(Enum):
    RED = 'r'
    GREEN = 'g'
    BLUE = 'b'


class MyModel(models.Model):
    name1 = models.CharField(max_length=250)
    name2 = models.CharField(max_length=250)
    color = EnumField(Color, max_length=1)

class MyModelFilterSet(FilterSet):
    class Meta:
        model = MyModel
        fields = [ 'color']

This code cause to render following filter

<select name="color" id="id_color">
  <option value="" selected="">---------</option>
  <option value="Color.RED">RED</option>
  <option value="Color.GREEN">GREEN</option>
  <option value="Color.BLUE">BLUE</option>
</select>

Wich leads to

'Color.RED' is not a valid Color

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions