# Django ChoiceField Empty String Value

**URL:** <https://forum.djangoproject.com/t/django-choicefield-empty-string-value/12458>\
**Category:** Templates & Frontend\
**Created:** [March 5, 2022, 9:53am UTC](https://forum.djangoproject.com/t/django-choicefield-empty-string-value/12458 "2022-03-05T09:53:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shawnngtq](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shawnngtq/32/5834_2.png) [@shawnngtq](https://forum.djangoproject.com/u/shawnngtq)\
**Post date:** [March 5, 2022, 9:53am UTC](https://forum.djangoproject.com/t/django-choicefield-empty-string-value/12458/1 "2022-03-05T09:53:27Z")

</div>

Hi, wondering if we can set empty string as value for select option?

Django version: 4.0.2

## Example

```python
CHOICE_LIST = [
    ("", "----"),
    (1, "Rock"),
    (2, "Hard Place"),
]

choices = forms.ChoiceField(
    choices=CHOICE_LIST,
    required=False,
)

```

The html generated is same for `("", "----")` and `(None, "----")`

```html
<select class="form-select form-select-sm mb-2" id="id_choices" name="choices">
  <option selected="">----</option>
  <option value="1">Rock</option>
  <option value="2">Hard Place</option>
</select>

```

If we use something else instead of `""` or `None` for value, it will be what I want:

```html
<select class="form-select form-select-sm mb-2" id="id_choices" name="choices">
  <option value="Somethingelse">----</option>
  <option value="1">Rock</option>
  <option value="2">Hard Place</option>
</select>

```

Reason I am using `""` is because this field is `TextField`

Thanks

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 5, 2022, 12:23pm UTC](https://forum.djangoproject.com/t/django-choicefield-empty-string-value/12458/2 "2022-03-05T12:23:49Z")

</div>

I can’t recreate the behavior you’re describing here. My rendering of that field generates:  
`<option value="" selected>-----</option>`

How are you rendering that field and those options? Are you overriding any of the system widgets? Or are you using a custom widget?

---

<div class="post-metadata">

**Author:** ![shawnngtq](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shawnngtq/32/5834_2.png) [@shawnngtq](https://forum.djangoproject.com/u/shawnngtq)\
**Post date:** [March 5, 2022, 12:49pm UTC](https://forum.djangoproject.com/t/django-choicefield-empty-string-value/12458/3 "2022-03-05T12:49:57Z")

</div>

I am using django widget tweaks, not using custom widget.

```nohighlight
{{ choices|add_class:"form-select form-select-sm mb-2" }}

```

I will try bootstrap a new instance and try this to confirm. Thanks for the pointer.

---

<div class="post-metadata">

**Author:** ![shawnngtq](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shawnngtq/32/5834_2.png) [@shawnngtq](https://forum.djangoproject.com/u/shawnngtq)\
**Post date:** [March 5, 2022, 1:32pm UTC](https://forum.djangoproject.com/t/django-choicefield-empty-string-value/12458/4 "2022-03-05T13:32:36Z")

</div>

I confirm you are right, this is not django issue, but other libraries’ fault, I am closing this

This is what I see in new setup.

```nohighlight
<select name="choices" id="id_choices">
  <option value="" selected="">----</option>
  <option value="1">Rock</option>
  <option value="2">Hard Place</option>
</select>

```
