Chaning app layout: automatically(!) store user input of all components

Hi all!

I duckducked for a solution… couldnt find one…

I would like to offer the user the ability to save all his inputs (to a database) to later on re-read it. In that way each user could have several “bookmarks” to reload previous input (and therefore plot) and could also share with other users…

As the dashboard layout WILL change from time to time I`m looking for a solution that ideally gets all dashboard elements and their current values automatically… (dcc.Input, dcc.Dropdown, …, …).

I´m not looking for defining a callback where I need to use each component as Input… that will work 100%… but is very time consuming and tedious work…

Any ideas/thoughts how to apporach this? Help very much appreciated!

Thanks n304win

1 Like


Welcome to the community!

All Dash components are basically dictionaries, so you can in principle save them as JSON or “stringfied” json. Here is a slightly related post about this particular point, however nothing is saved in a database…

If you are interested in saving inputs and selections, I would also encourage you to take a look on persistent props, which saves some of the selections in the browser cache. It is a bit more limited but simpler, since you don’t have to deal with user authentication and DB I/O.

I hope you’ll find this helpful, even if it is not exactly what you are looking for.

Thanks @jlfsjunior for your repsonse.

Persistence is nice, but not exactly what I´m looking for, also dcc.Store is not 100% what i need.

My current workaround is that I assign to each element not a string-id but a dict-id like i.e. id={‘id’: ‘currentElement’}. So with Input({‘id’: ALL}, ‘value’) I can simply save all elements current values with pattern matching. Not ideal but somehow the best workaround for now… so with new elements I dont have to change the “store”-callback as all elements are catched by pattern matching as well…