dcc.Download callback with send_data_frame

Hi,
I am following the Download documentation here:

to try to get the Excel download to work.
I can confirm that the dataframe I am sending to Excel is just a regular pandas DataFrame.
When the callback triggers, and outputs to dcc.Download data, I get an error saying that data is expecting a tuple or a list, and not a dict.

Here is the exact error (with content removed)

dash._grouping.SchemaTypeValidationError: Schema: [<Output `excel-download.data`>]
Path: ()
Expected type: (<class 'tuple'>, <class 'list'>)
Received value of type <class 'dict'>:
{'content': 'REMOVED TOO LONG', 'filename': 'mailing.xlsx', 'type': None, 'base64': True}

I am on
dash 2.8.1
dcc 2.0.0

The source code clearly says dcc.Download is expecting a Dict in data, so I presume it is just the schema checker throwing up on me?
Any insights are appreciated.

Kind Regards,
Jason

Hi, @jasochang , welcome to the forums. Try wrapping your returned value with []

Hi @AIMPED,

Thank you. That worked.
I must have came across this error a million times and fixed it.
I guess it would be super helpful to update the documentation to include the

Glad it works now. If you wrap your Output() in a list, you have to return a list. I’m pretty sure this is documented somewhere.

Oh… in the decorator. I understand now. Thank you!

1 Like