Hi everyone,
I have noticed an issue when deploying my multipage Dash app where sometimes a page will not be registered despite it being set up correctly. However, if I merely change the name of the page’s python script file (to any other random name) it will then be registered and function normally.
This is a bit frustrating as I have many page scripts and would like to give them specific names to help organise them.
There are even instances where I can deploy the app locally on my PC and the pages are all register ok, but if I deploy them elsewhere (i.e. cPanel) some pages are not registered but by only changing their files names this is fixed.
Does anyone know what could be causing this issue?
Any help would be much appreciated.
Kind regards,
Jessica
this-page.py
#Relevant modules imported here
import dash
#Register the page
page_name = "this_page_name"
dash.register_page(__name__,
name = page_name, #Used by app.py
path="/the-path-for-this-page", #Unique for each page
order = 0
)
app.py
import dash
from dash import html
dash.register_page(__name__,
name = "App Name",
path="/the-path-for-this-app"
)
layout = html.Div(
[
dbc.Row([
dbc.Col([
dbc.Nav(
[
dbc.NavLink([
html.Div(page["name"], className = "ms-2"),
],
href = page["relative_path"],
active = "exact",
#active = True,
)
for page in dash.page_registry.values()
if page["name"].startswith(("this_page_name")) #Only want specific pages to be displayed in the container
],
vertical = True,
pills = True,
className = "bg-light",
)
])
]),
]
)
With this example, the page will not be registered but if I only change the page file name from this-page.py to alternative-this-page.py, then it will work.