How to create many pages from different datasets without a separate py file for each dataset?

HI @Travelmug

I’m guessing that you are fairly new to Dash? If so, I’d recommend breaking things down into smaller pieces and get those working first. If you create a minimal example and use sample data, then if you get stuck then we would have a complete example to run. You can find more info here: How to Get your Questions Answered on the Plotly Forum

For example, you could first make a single page app that handled all the report variations for one report type. Be sure to review the this section of the docs on sharing data between callbacks.

Next step, if you are using large data (ie millions of rows) use the Background callbacks rather than functools.lru_cache

Once that is working, the next step could be turning it into a multi-page app. Note that when using pages, it will automatically import the layouts from the pages folder, and create the routing callback for you “under the hood”. Some of your errors are probably because your layouts are being imported twice. Note also that you can’t include callbacks inside the layout function. More info here: Callback Gotchas | Dash for Python Documentation | Plotly

When you get to the point of making a multi-page app, it will be helpful to clone this reop and run the examples locally so you understand how to structure a mult-page app and start with a working app frame.

I hope this helps!

1 Like