ID not found in layout > when I want to click on the submit button

Hello so,when I go to my app and when I click on submit nothing happens,I only get errors like this:

Attempting to connect a callback Input item to component:
“submit”
but no components with that id exist in the layout.

If you are assigning callbacks to components that are
generated by other callbacks (and therefore not in the
initial layout), you can suppress this exception by setting
suppress_callback_exceptions=True.
This ID was used in the callback(s) for Output(s):
alert7.children
I did try adding
app.config[‘suppress_callback_exceptions’] = True
app.config.suppress_callback_exceptions = True

but that only stopped showing the errors,still when I click submit,it doesn’t work.Can you please help?


from apps.app1 import input_check_cycle_time_and_efficiency

import dash_bootstrap_components as dbc

import dash_core_components as dcc

import dash_html_components as html

from dash.dependencies import Input, Output, State

import datetime

#import connect

import pandas as pd

from app import app

from datetime import datetime as dt

from datetime import timedelta

import dash

import plotly.graph_objects as go

import distutils.dist

import utils

import constants

import mssql_queries

import mssql_conn

import mysql_queries

import base64

import io

import flask 

import os

import sys

from waitress import serve

import json

#import kaleido

import plotly

import base64

from app import app

import utils

import mysql_queries

import mssql_queries

import mssql_conn

import constants

def convert_timedelta(timedelta):

    total_seconds = timedelta.total_seconds()

    hours = int(total_seconds // 3600)

    minutes = int(total_seconds // 60 % 60)

    seconds = int(total_seconds % 60)

    if hours < 10:

        hours = "0" + str(hours)

    if minutes < 10:

        minutes = "0" + str(minutes)

    if seconds < 10:

        seconds = "0" + str(seconds)

    return str(hours) + ":" + str(minutes) + ":" + str(seconds)

def convert_timedelta(timedelta):

    total_seconds = timedelta.total_seconds()

    hours = int(total_seconds // 3600)

    minutes = int(total_seconds // 60 % 60)

    seconds = int(total_seconds % 60)

    if hours < 10:

        hours = "0" + str(hours)

    if minutes < 10:

        minutes = "0" + str(minutes)

    if seconds < 10:

        seconds = "0" + str(seconds)

    return str(hours) + ":" + str(minutes) + ":" + str(seconds)

def convert_time_to_string(timedelta):

    total_seconds = timedelta

    hours = int(total_seconds // 3600)

    minutes = int(total_seconds // 60 % 60)

    seconds = int(total_seconds % 60)

    if hours < 10:

        hours = "0" + str(hours)

    if minutes < 10:

        minutes = "0" + str(minutes)

    if seconds < 10:

        seconds = "0" + str(seconds)

    return str(hours) + ":" + str(minutes) + ":" + str(seconds)

def convert_time_to_string_to_minutes(time_string):

    indices = time_string.split(":")

    indices = [int(i) for i in indices]

    total_time = int(indices[0] * 60 + indices[1] + indices[2] / 60)

    return total_time

    

controls = dbc.FormGroup(

    [

        dbc.Row([

            dbc.Col(

            html.Div(["Start Time: ", constants.start_date_picker],

                    ),

                ),

            dbc.Col(

                html.Div([ constants.start_time_picker ])

            )

        ],style={"marginBottom":"0.5em"}),

                dbc.Row([

            dbc.Col(

            html.Div(["End Time: ", constants.end_date_picker]),

                ),

            dbc.Col(constants.end_time_picker 

                ),

        ]),

     html.Hr(),

    dbc.Row([

        dbc.Col([

                    html.Div(["Theoretical Cycle Time (in s):"]),

            ]),

        dbc.Col([

                   dcc.Input(id="taktzeit", type="text", persistence=True, required=True),

            ])

    ],style={"marginBottom":"0.5em"}

    ),

    dbc.Row([

        dbc.Col([

                    html.Div(["Theoretical Efficiency (in %)"])

            ]),

        dbc.Col([

                   dcc.Input(id="effizienz", type="text", persistence=True, required=True)

            ])

    ],style={"marginBottom":"0.5em"}),   

    # html.Hr(),

    # dbc.Row([

        # dbc.Col([

        #     # html.Div(["Planned Qty"]),

        # ]),

    # dbc.Col([

    # dcc.Input(id="planned_qty", type="text", persistence=True, required=True),

    # ])

    # ],style={"marginBottom":"0.5em"}

    #  ),

    # html.Hr(),

    dbc.Row([

         dbc.Col([

                     html.Div(["Database"])

             ]),

         dbc.Col([

                     constants.database

             ])

     ],style={"marginBottom":"1em"}),          

    dbc.Row([

        dbc.Col([

                    html.Div(["Type"])

            ]),

        dbc.Col([

                    constants.part_type_selection

            ])

    ],style={"marginBottom":"1em"}),

    dbc.Row([

        # dbc.Col([

        #             html.Div(["Worker Name"])

        #     ]),

        # dbc.Col([

        #             constants.worker_selection

        #     ])

    ],style={"marginBottom":"1em"}),

    dbc.Row([

        dbc.Col([

                    html.Div(["Language"])

            ]),

        dbc.Col([

                    constants.language

            ])

    ],style={"marginBottom":"0.5em"}),

    html.Hr(),

    dbc.Button(

        id='submit_button',

        n_clicks=0,

        children='Submit',

        color='primary',

        block=True

        ),

    html.Hr(),

    html.Div(id="alert31"),

    html.Div(id="alert32"),

    html.Div(id="link7")

    ]

)

sidebar = html.Div(

    [

        html.H2('APP7', style=constants.TEXT_STYLE),

        # html.H3('Parameters', style=constants.TEXT_STYLE),

        html.Hr(),

        controls

    ],

    style=constants.SIDEBAR_STYLE,

)

content = html.Div(

    [

        dcc.Tabs([

            dcc.Tab(label='Bar Chart', children=[

                dcc.Store(id="query_output"),

                dcc.Store(id="shift_filter"),

                dcc.Store(id="excel_data11"),

                dcc.Store(id="excel_data12"),

                dcc.Graph(id="bar_chart", style={"height":800}),

                dbc.Row([

                    dbc.Col([

                        html.Div(children=html.Strong(id='fehler_zah'))

                    ]),

                    dbc.Col([

                        html.Div(children=html.Strong(id='fehler_dauer'))

                    ]),

                    dbc.Col([

                        html.Div(children=html.Strong(id="verlust_menge"))

                    ])

                ])

            ]),

            dcc.Tab(label='Pie Chart', children=[

                dcc.Graph(id="pie_chart", style={"height":800}),

            ]),

        ]),

    ],

    style=constants.CONTENT_STYLE,

    id="content"

)

layout = html.Div([sidebar, content])

def boolean_helper(selector):

    if len(selector) > 1:

        return True

    else:

        return False

@app.callback(

    [Output("alert7", "children")],

        Input("submit", "n_clicks"),

        state=[

            State("start_date_picker", "date"),

            State("start_time_picker", "value"),

            State("end_date_picker", "date"),

            State("end_time_picker", "value"),

            State("database", "value")

            ])

def show_erros(n_clicks, start_date_picker, start_time_picker, end_date_picker, end_time_picker, databse):

    print("asdf")

    if n_clicks:

         start_time = datetime.datetime.strptime(start_date_picker, "%Y-%m-%d") + datetime.timedelta(hours=int(start_time_picker[0:2]))

         end_time = datetime.datetime.strptime(end_date_picker, "%Y-%m-%d") + datetime.timedelta(hours=int(end_time_picker[0:2]))

         parameters = [start_time, end_time]

         print("is executed")

         query_string = mssql_queries.build_db_query_string_app7()

         records = mssql_conn.execute_query(query_string, parameters, str(databse))

         

def input_check_time(start_time, end_time):

         if end_time < start_time:

             return dbc.Alert("End Time has to be bigger than starting time", color="danger", duration=5000)

         return None

this is my index.app

import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from app import app
from apps import app1, app2, app3, app4, app5, app6, app7
import nav

app.layout = html.Div([
    dcc.Location(id='url', refresh=False),
    html.Div(id='page-content')
])

@app.callback(Output('page-content', 'children'),
              [Input('url', 'pathname')])
def display_page(pathname):
    if pathname == "/":
        return nav.layout
    elif pathname == '/apps/Downtime_and_Reasons':
        #app.title = "Downtime and Reasons"
        return app1.layout
    elif pathname == "/apps/Report_of_Check_Criteria":
        #app.title = "Report of Check Criteria"
        return app2.layout
    elif pathname == "/apps/Quantity_and_Scrap":
        #app.title = "Quantity and Scrap"
        return app3.layout
    elif pathname == "/apps/User_Log":
        #app.title = "User Log"
        return app4.layout
    elif pathname == "/apps/Error_Log":
        #app.title = "Error Log"
        return app5.layout
    elif pathname == "/apps/Error_Log":
        #app.title = "Error Log"
        return app5.layout
    elif pathname == "/apps/Parameter_Log":
        return app6.layout
    elif pathname == "/apps/app7":
        return app7.layout
    else:
        return '404'

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

It works now,I just needed to add in the code the following

dbc.Button(

        id='submit_button',

        n_clicks=0,

        children='Submit',

        color='primary',

        block=True

        ),

    html.Hr(),

    html.Div(id="alert7"),

    html.Div(id="alert12"),

    html.Div(id="alert13"),

    html.Div(id="link7"),

    html.Div(id="link12")