My all application is build on 2 main parameters: the geometry name and the crop name. Everything downstream is piloted from these 2 values.
To simplify let’s only focus on the cropname for now. I have a dash application with a dcc.Store object ich is the Input of every graph in the application.
My application have multiple page so to access the crop page I go to the “/crop/<crop_name>/” name url and from my application I use the following:
thanks for your suggestion, I’m well aware of this documentation page. I’m actually looking for a fonctionality that looks like " Additional Inputs to the Pages Routing" but I would need it to be page related instead of application related.
I’m working with the following super simple application:
# app.py
import dash
from dash import html
app = dash.Dash(__name__, use_pages=True)
# set a title and a store in the layout
app.layout = html.Div([
html.H1('Displaying store content'),
dash.page_container
])
app.run_server(debug=True)
And the following parametrized page:
# pages/page1.py
import dash
from dash import html
from dash import dcc, Input, Output
app = dash.get_app()
content = html.H2("Nothing to see here.", id="title")
layout = html.Div([
content,
dcc.Store(id='store', data=None),
])
@app.callback(
Output(content.id, "children"),
[Input("store", "data")]
)
def display_store_data(data):
return html.Pre(repr(data))
dash.register_page(__name__, path_template="/crop/<crop_name>", name="Crop")
I want to find a mechanism to feed the “crop_name” value to the dcc.Store object when I reach the page. I need to use a dcc store object because it’s in my real case used to trigger all the downstream page modifications.
My objective is to avoid use of the dcc.Location object as I have other part of my application writing the same thing to it. Also We have multiple url redirection depending on the deployment mechanism and registe_page was transparent when it comes to url parsing when dcc.Location needs to know if a prefix is applied.
I thinkwhat I’m trying to achieve is simply not possible in Dash, that’s the first time I deal with a stateless dashboarding tool and it’s very complicated to migrate what I know.
Thank you very much for your answer and I hope it will be useful to someone else!