Closed
Description
Given the following model
class MyModel(models.Model):
class MyChoices(models.TextChoices):
A = "a"
B = "b"
C = "c"
my_field = EnumField(MyChoices, null=True, blank=True, default=None)
I would have expected MyModel(my_field="").full_clean()
to throw a ValidationError, but instead it throws a ValueError in the coercion step.
Apart from that, kudos to you and your library, that you throw an error at all. Im quite happy that I have found it.
I was growing quite frustrated with the Django CharField based approach wrt. to nullable enum fields. It is infuriating that one is required to set blank=true
to allow setting those fields to None/Null, which then automatically implies that an empty string is also allowed and it even sets default="" by default. I mean why?!