# Filling a checklist through a callback

**URL:** https://community.plotly.com/t/filling-a-checklist-through-a-callback/7435
**Category:** Dash Python
**Created:** [December 21, 2017, 10:20am UTC](https://community.plotly.com/t/filling-a-checklist-through-a-callback/7435 "2017-12-21T10:20:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rauldom](https://avatars.discourse-cdn.com/v4/letter/r/77aa72/32.png) [@rauldom](https://community.plotly.com/u/rauldom)
#### Post date: [December 21, 2017, 10:20am UTC](https://community.plotly.com/t/filling-a-checklist-through-a-callback/7435/1 "2017-12-21T10:20:13Z")

</div>

Hello everyone!

First of all, thank you for this wonderful library.

I have a problem to fill a Checklist through a callback. My code is the next:

```auto
import dash
from dash.dependencies import Input, Output, State
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.css.append_css({'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'})

  

app.layout = html.Div(
			children = [
				html.Div(
				id = 'list',
				children = [dcc.Checklist(id = "myList")]),
			html.Button('Fill Checklist', id='list-btn', n_clicks=0)]
			)

@app.callback(
	Output('myList', 'options'),
	[Input('list-btn', 'n_clicks')]
	)
def fillChecklist(n_clicks):
    data = [['label-1', '1'],['label-2', '2']]
    return [{'label': x[0] +" "+ x[1], 'value' : x[1] } for x in data]

if __name__ == ' __main__':
    app.run_server(debug=True)

#dcc.RadioItems

```

and i got:

![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/3/38bc951dc1a8ec5659e91f68ea7a1bb234915ba7.png)

the console shows:

```auto
127.0.0.1 - - [21/Dec/2017 04:04:07] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [21/Dec/2017 04:04:11] "GET /_dash-layout HTTP/1.1" 500 -
Traceback (most recent call last):
  File "C:\Users\Raul\Anaconda3\lib\site-packages\flask\app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Users\Raul\Anaconda3\lib\site-packages\flask\app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "C:\Users\Raul\Anaconda3\lib\site-packages\flask\app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\Raul\Anaconda3\lib\site-packages\flask\_compat.py", line 33, in reraise
    raise value
  File "C:\Users\Raul\Anaconda3\lib\site-packages\flask\app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\Raul\Anaconda3\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\Raul\Anaconda3\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\Raul\Anaconda3\lib\site-packages\flask\_compat.py", line 33, in reraise
    raise value
  File "C:\Users\Raul\Anaconda3\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\Raul\Anaconda3\lib\site-packages\flask\app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\Raul\Anaconda3\lib\site-packages\dash\dash.py", line 165, in serve_layout
    cls=plotly.utils.PlotlyJSONEncoder),
  File "C:\Users\Raul\Anaconda3\lib\json\ __init__.py", line 237, in dumps
    **kw).encode(obj)
  File "C:\Users\Raul\Anaconda3\lib\site-packages\plotly\utils.py", line 136, in encode
    encoded_o = super(PlotlyJSONEncoder, self).encode(o)
  File "C:\Users\Raul\Anaconda3\lib\json\encoder.py", line 198, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Users\Raul\Anaconda3\lib\json\encoder.py", line 256, in iterencode
    return _iterencode(o, 0)
  File "C:\Users\Raul\Anaconda3\lib\site-packages\plotly\utils.py", line 204, in default
    return _json.JSONEncoder.default(self, obj)
  File "C:\Users\Raul\Anaconda3\lib\json\encoder.py", line 179, in default
    raise TypeError(repr(o) + " is not JSON serializable")
  File "<string>", line 52, in __repr__
    
  File "<string>", line 52, in <listcomp>
    
  File "<string>", line 52, in __repr__
  .......

    
RecursionError: maximum recursion depth exceeded while calling a Python object
127.0.0.1 - - [21/Dec/2017 04:04:11] "GET /_dash-dependencies HTTP/1.1" 200 -
127.0.0.1 - - [21/Dec/2017 04:04:11] "GET /favicon.ico HTTP/1.1" 200 -

```

When I change the dcc.Checklist() for dcc.RadioItems() the code worrks fine:

![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/2/28c9cae1df41e865bfe587c4b10ba4f9789c888f.png)

I don’t know what I’m doing wrong or if it’s a kind o bug. I would greatly appreciate your help or I want to know if someone has another way to fill a checklist.  
Thank’s

---

<div class="post-metadata">

### Author: ![nedned](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/nedned/32/8795_2.png) [@nedned](https://community.plotly.com/u/nedned)
#### Post date: [December 22, 2017, 1:47pm UTC](https://community.plotly.com/t/filling-a-checklist-through-a-callback/7435/2 "2017-12-22T13:47:07Z")

</div>

The problem is that the checklist component must have an initial value provided for its `values` attribute. Even though you’re generating the value of that attribute with the callback, the component must have a specified value on initialisation. `values=[]` seems to make it happy.

Edit: I’ve just filed an issue over on the dash-core-components repository about this – [https://github.com/plotly/dash-core-components/issues/133](https://github.com/plotly/dash-core-components/issues/133)

---

<div class="post-metadata">

### Author: ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)
#### Post date: [December 22, 2017, 5:32pm UTC](https://community.plotly.com/t/filling-a-checklist-through-a-callback/7435/3 "2017-12-22T17:32:00Z")

</div>

I commented about this in the issue above ([https://github.com/plotly/dash-core-components/issues/133#issuecomment-353641641](https://github.com/plotly/dash-core-components/issues/133#issuecomment-353641641)). Thanks for reporting and triaging!
