Suppress_callback_exception is not working

The below app is functioning correctly, and per the error message, I have stated suppress_callback_exceptions=True since I am ‘assigning callbacks to components that are generated by other callbacks’

However, I continue to get ID not found in layout errors.

What am I doing wrong?

from dash import Input, Output, State
from dash.exceptions import PreventUpdate
from dash import html, dcc
import dash_bootstrap_components as dbc

app = dash.Dash(
    __name__,
    prevent_initial_callbacks=True,
    suppress_callback_exceptions=True
)


def login_layout():
    return html.Div([
    dbc.Input(id='username', placeholder="username", autofocus='True'),
    dbc.Input(id='password', placeholder="password"),
    dbc.Button('submit', id='button'),
    html.Div(id='message')
    ], id='main_div')


def app_layout():
    return html.Div([
        dbc.Row([
            dbc.Col([
                dcc.Dropdown(['a', 'b'], id = 'test2'),
                dcc.Dropdown(['c', 'd'], id = 'test1'),
                dbc.Input(id='input1'),
                dbc.Input(id = 'input2'),
                html.Div(id='appchild')
            ])
        ])
    ])


app.layout = login_layout()

d = {'user1':'pw1', 'user2':'pw2'}


@app.callback(
    Output('main_div', 'children'),
    Output('message', 'children'),
    Input('button', 'n_clicks'),
    State('username', 'value'),
    State('password', 'value')
)
def upload_template(n_clicks, username, password):
    if n_clicks:
        if d.get(username) == password:
            print(username)
            return app_layout(), None
        else:
            return login_layout(), 'Incorrect Password'
    else:
        raise PreventUpdate


@app.callback(
    Output('appchild', 'children'),
    Input('test2', 'value'),
    Input('test1', 'value')
)
def upload_template(value1, value2):
    return value1 + value2

if __name__ == '__main__':
    app.run_server(debug=True)

Hi @anarchocaps when I ran your code I didn’t get an ID not found in layout error, but I did get:

TypeError: can only concatenate str (not “NoneType”) to str

The error is in this line, since the dropdown values are None.
return value1 + value2

1 Like