Bug - cannot register not_found_404 with dash.register_page()

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 @marketemp

This is the same issue as your other post - see more info here: Bug - Dash Pages does not find pages with underscores - #2 by AnnMarieW

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")

image

Path with dashes (the defualt)

register_page("my_home_page", layout=html.Div("my_home_page"))

image



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?

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