✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Embedding dash to pre-existing django app

i have dash.py file in which i have created a dash which includes some graphs and data table.
how can i embed this dash.py file into a pre-existing django app.
(like i have a django-dashboard created, i need to add a statistics button in the django dashboard and when clicked on it my dash.py file should and and execute the graphs created using dash.
can u please help me out in this?)

If you’re going to run your dash app inside django, then take a look at django-plotly-dash.

If however you’re going to run a separate server, then embedding in an <iframe> is probably the cleanest way.

can you give an example of how to embed iframe in the django? @chriddyp @delsim

@Sam2 - if you want to use Django to also serve up the dash app then look at django-plotly-dash in the link above. It provides a template tag for embedding Dash apps in an iframe along with other necessary infrastructure.

On the other hand, if you just want to refer to a Dash app served elsewhere, then put the url into an iframe element in a Django template - something along the lines of

<iframe (various parameters like height etc) src="https://dash_server_url"></iframe>

Note that this is a general Django use case, and there is nothing Dash specific in it. The dash_server_url must be accessible to the client.

Thank you! I got it @delsim