# Error "Select a valid choice"

**URL:** <https://forum.djangoproject.com/t/error-select-a-valid-choice/1991>\
**Category:** Using Django\
**Created:** [April 16, 2020, 8:27am UTC](https://forum.djangoproject.com/t/error-select-a-valid-choice/1991 "2020-04-16T08:27:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitagora04](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/pitagora04/32/1019_2.png) [@pitagora04](https://forum.djangoproject.com/u/pitagora04)\
**Post date:** [April 16, 2020, 8:27am UTC](https://forum.djangoproject.com/t/error-select-a-valid-choice/1991/1 "2020-04-16T08:27:59Z")

</div>

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 `Article`model but it seems I have not enough experience with Django to immediately feel where to go next 🙂 .

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)
```

---

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [April 16, 2020, 9:05am UTC](https://forum.djangoproject.com/t/error-select-a-valid-choice/1991/2 "2020-04-16T09:05:17Z")

</div>

> [@pitagora04](#):
>
> One of my attributes in `Article` model is set to have the values selected from Enum.

Rather than using an `Enum` directly, you should consdier Django 3’s [enumeration types](https://adamj.eu/tech/2020/01/27/moving-to-django-3-field-choices-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.

---

<div class="post-metadata">

**Author:** ![pitagora04](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/pitagora04/32/1019_2.png) [@pitagora04](https://forum.djangoproject.com/u/pitagora04)\
**Post date:** [April 16, 2020, 9:11am UTC](https://forum.djangoproject.com/t/error-select-a-valid-choice/1991/3 "2020-04-16T09:11:32Z")

</div>

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)**
