Announcing Dash Bio 1.0.0 ๐ŸŽ‰ : a one-stop-shop for bioinformatics and drug development visualizations.

Got duplicate callback output after refreshing the page


I made a multi-page app and once I change my url to shift one page to another page or even when I refresh the current page, there will be a duplicate callback output error.
Besides, I encapsulated my function into a function and return the layout to my index.py to show it, but it seems like all the callbacks are not shown when I open the url, only if I refresh the page will it update the callbacks.
I have totally no idea, is there anyone to help me with that? Thanks a lot

1 Like

I have the same problem but still canโ€™t figure it out

In Dash, you can only assign at most one callback to target an item (Output(...)) in the layout.

Below is not possible (itโ€™s just to demonstrate the point):

@app.callback(
    Output("some-element-id", "children"),
    [Input(...)]
)
def do_something():
    # ...

@app.callback(
    Output("some-element-id", "children"),
    [Input(...)]
)
def do_another_thing():
    # ...

Iโ€™m wondering if you have duplicate code for each of your pages in your multi-page app.

Would you mind posting your code in this thread?

I also encountered this error when I moved a callback from outside of a function that is returned to within that function. For example in index.py which sets my layout for my multipage app:

@app.callback(Output('page-content', 'children'),
              [Input('url', 'pathname')])
def display_page(pathname):
    if pathname is None:
        home = layout_function(pathname)
        return home

And then in my home.py app:

# I moved the some-element-id callback into layout_function from outside of it. 
def layout_function(pathname):

       @app.callback(
       Output("some-element-id", "children"),
       [Input(...)]
   )
   def do_something():
       # ...
   return home_layout

# Previously this was outside the function and worked fine. 
@app.callback(
    Output("some-element-id", "children"),
    [Input(...)]
)
def do_another_thing():
    # ...

It seems like the callbacks within my function are being sent again.

This issue is in dash 1.6.0 though it seems like pattern matching callback may actually fix my issue. Perhaps I need to upgrade.