Skip to content

TextChoices are not rendered as enum when a field is not editable #1407

@rixx

Description

@rixx

Describe the bug

When I switch a model field from editable=True to editable=False, the documentation correctly still lists the field in reading (list, retrieve, etc) views, but stops including the enum.

To Reproduce

class TestChoices(models.TextChoices):
    TEST = "test"

class TestModel(models.Model):
    test_role = models.CharField(choices=TestChoices.choices, max_length=4, null=True, default=None, editable=True)

class TestModelSerializer(serializers.ModelSerializer)
    class Meta:
        model = TestModel
        fields = ("id", "test_role")

Generate a schema, observe the enum present, then switch the test_role field to editable=False and see the enum disappear.

I tried turning COMPONENT_SPLIT_REQUEST off, which I usually have on, but the setting doesn’t make a difference (not that it should, just reporting this attempt for completeness).

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