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:
it does not register and the default 404 - Page not found output is returned
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)
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
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?
nope that does not work with any of the variants
register_page(__name__) 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
@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.