Hi,
I have a multipage Dash app. I have a simple button that triggers a callback to get a value from a mongodb. Some queries take quite long, so I wanted to store the values to not lose them when I change the page. The callback looks like this:
@callback(
output=[
Output('profile-count', 'children'),
Output('intermediate-profile-count', 'data'),
],
inputs=[
Input('profile-count-btn', 'n_clicks'),
Input('intermediate-profile-count', 'data'),
])
def get_value(n_clicks, data):
if data is None:
if n_clicks!=0:
num_profiles = get_value_from_db
return html.P(f"{format(num_profiles, ',d').replace(',', '.')}", className="card-text"), json.dumps(num_profiles, default=str)
else:
return no_update, no_update
else:
num_profiles = json.loads(data)
return html.P(f"{format(num_profiles, ',d').replace(',', '.')}", className="card-text"), data
It works as expected when I put the dcc.Store() in my app.py and the callback is located in pages/get_values.py.
But I get an error telling me that:
A nonexistent object was used in an
Inputof a Dash callback
This is probably because the inputs/outputs are in different locations. Putting the dcc.Store in pages/get_values.py doesn’t work.
Is there a way to avoid the error, like making the app.py aware of the button-id?
Thanks