models.TextChoices with blank=True

Hello everybody!

When I use models.TextChoices to create class with choices, with blank=True, I expect that I can leave this choice field not fillable(with number of dashes). But I can’t. Django raise an error, it want from me to add None or '' (blank line) to the list of choices. Like this:

class SomeType(models.TextChoices)
    NOT_SELECTED = None, '---------'
    FIRST_TYPE, 'first_type', 'first type'
    ...

Is this correct behaviour? Maybe I miss something? I thought this cases should processed by Django itself.

What specific error is raised, and where in your code? (Please post the error message with the full traceback from your server log, along with your model definition.)

Sorry, my mistake. Django work as expected. It’s my code try to ask SomeType to get the current blank choice. Thank you for your reply!

i think you want this.

models.TextField(choices=['a', 'b', 'c',], blank=True)