Given the following model:
from django.db import models
class my_choice(models.TextChoices):
YES = "Y", "Yes"
NO = "N", "No"
class DemoClass(models.Model):
the_choice = models.CharField(
max_length=2,
choices=my_choice.choices,
default=my_choice.YES
)
the function refresh_from_db()
alters the type of the field the_choice
:
>>> from refresh.models import DemoClass
>>> d = DemoClass.objects.create()
>>> type(d.the_choice)
<enum 'my_choice'>
>>> d.refresh_from_db()
>>> type(d.the_choice)
<class 'str'>
Is this behavior intentional?