So!
I am working on a project where I need to create the same component with a different idea a couple of times.
and for each component, I am creating the same callback just with a different output
def createCallback(id):
app.callback(
Output(id, 'children'),
Input(id, 'n_clicks')
)(callback_function)
def callback_function(n_clicks):
print(n_clicks)
return n_clicks
The code is something I came on the spot but does the job as an example for the callback creation.
Now I pass all of my objects creation as functions and to the layout, I pass a function so it will render the app from scratch each time a user is opening the app / refreshing it.
app.layout = generateAppLayout
and because I create the app from scratch it creates the callbacks again and thus the “Duplicate callback outputs” come to the picture. (i have to refresh the app because they have a button where they upload data to the database and I need to load the new data that was inserted by the user)
any idea how I can fix this problem? I thought about a few ideas which I have no idea how I can implement
- find a way to check if a callback exists with a specific output and create the callback only if it doesn’t exist
- find a way to delete the callback if the app is reloaded
thanks for taking the time to read! if you know how to implement the ideas I wrote/got an idea of your on please do share!
5 posts - 3 participants







