TIL: Plotly Dash uses the order of the pages in the pages registry to evaluate whether the requested URL matches a page's `path_template` value. By default, pages are ordered alphabetically based on the pages filename.

In my case, I had two pages defined with the following `path_template` values:
- `/datasets/<dataset_id>` in `pages/dataset.py`
- `/datasets/<dataset_id>/labelsets/<labelset_id>` in `pages/labelset.py`

When trying to open a URL matching the second template, it was matching the first one and using the remainder of the URL as `dataset_id`.

Setting the `order` parameter in the `dash.register_page()` function changes the order of the pages in the page registry, thus changing the path matching order. To match the longest/nested `path_template`, the corresponding page has to be registered with a lower `order` value.

That makes sense in hindsight but the docs do not mention that the path evaluation is affected by the page order.

https://dash.plotly.com/urls

#Plotly #PlotlyDash #Dash #Python #WebDev

Multi-Page Apps and URL Support | Dash for Python Documentation | Plotly

Dash provides two components (`dcc.Link` and `dcc.Location`) that allow you to easily make fast multipage apps using its own Single Page App (SPA) design pattern.

📊🚀 Zajímá vás tvorba interaktivních datových aplikací? Přijďte na workshop "Interaktivní (nejen) datové aplikace s Plotly Dash" vedený Martinem Rapavým! 👨‍💻🤩 https://cz.pycon.org/2023/program/workshops/23/
#PlotlyDash #PythonWorkshop
PyCon CZ – Interaktivní (nejen) datové aplikace s Plotly Dash – a workshop by Martin Rapavý

U každého (nielen) dátového projektu v Pythone nastane chvíľa, keď potrebujeme svoje zistenia prezentovať. Môže sa jednať o náš model strojového učenia, výsledky dátovej analýzy alebo len zobrazenie zaujímavých dát. Často sa ale nejedná o jednorazové úlohy ale komplexné projekty, ktoré potrebujeme …

PyCon CZ 23