As described within Multi-Page Apps and URL Support | Dash for Python Documentation | Plotly , creating a /pages/not_found_404.py file allows you to define custom 404 functionality. However when I try to do the same using:
dash.register_page("not_found_404", layout=html.Div("not_found_404"))
it does not register and the default 404 - Page not found output is returned
1 Like
Hi @AnnMarieW
I understand itās the same issue with underscores, but I cannot determine how to resolve it correctly using that feedback or any of the examples?
Did you run the example I posted in the other topic? Itās common to use underscores in the module name.
Path with underscores (not recommended)
register_page("my_page", layout=html.Div("my_page"), path="/my_page")
Path with dashes (the defualt)
register_page("my_home_page", layout=html.Div("my_home_page"))
You will find lots of examples of module names with underscores here. I recommend cloning this repo and running the examples locally.
I understand that already for pages Iāve defined. What Iām asking is how to get
dash.register_page("not_found_404", layout=html.Div("not_found_404"))
to work. I can only get this working using /pages/not_found_404.py
The docs say to name it
_ _ name _ _ ā canāt use code tags on phoneā¦
Instead of trying to use the underscores.
Maybe that is the issue somehow?
luggie
November 10, 2022, 9:56am
7
nope that does not work with any of the variants
register_page(__name__) layout = ...
or register_page('not_found_404", layout='...')
or register_page('not-found-404", layout='...')
ā The page is registered as /not-found-404, but it does NOT serve as custom 404 page as described here: Multi-Page Apps and URL Support | Dash for Python Documentation | Plotly
nedned
December 13, 2022, 9:57am
8
@marketemp try updating to the latest Dash. I think this was actually caused by a known bug where custom 404 pages (whether set by a pages/not_found_404.py
or by an inline dash.register_page("not_found_404", layout)
) didnāt work with Dash Pages.
This was fixed in Dash 2.7.0.
1 Like