Error "Select a valid choice"

I’m getting error Select a valid choice. LanguageChoice.EN is not one of the available choices. for select input in my form.
I have registered Admin interface ArticleAdmin for my model class Artcile.
One of my attributes in Article model is set to have the values selected from Enum.
How can I solve this ?
I guess I have to set some validation rules somewhere or move this choices out of Articlemodel but it seems I have not enough experience with Django to immediately feel where to go next :slight_smile: .

Please see the code.

This classes I have in models.py

class LanguageChoice(Enum):
    EN = "English"
    DE = "German"
    IT = "Italian"

class Article(models.Model):
    title = models.CharField(max_length=100)
    author = models.CharField(max_length=50)
    language = models.CharField(
        max_length=2,
        choices=[(tag, tag.value) for tag in LanguageChoice],
        default=LanguageChoice.EN
    )

Then in admin.py I have:

class ArticleAdmin(admin.ModelAdmin):
    fields = ['title','author','language']

admin.site.register(Article, ArticleAdmin)

Rather than using an Enum directly, you should consdier Django 3’s enumeration types which subclass Enum.

As for your error, I believe you can solve with default=LanguageChoice.EN.name. But the enumeration types make this easier.

Thank you for your answer.

Based on your comment I modified the code in models.py this way:

class LanguageChoice(models.TextChoices):
    EN = "EN", "English"
    DE = "DE", "German"
    IT = "IT", "Italian"

class Article(models.Model):
    title = models.CharField(max_length=100)
    author = models.CharField(max_length=50)
    language = models.CharField(
        max_length=2,
        choices=LanguageChoice.choices,
        default=LanguageChoice.EN
    )

And next question, is it possible to eliminate some of this languages from select input ?
(so language should stay here in model, but I don’t want to show it in select input)