Hi
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.
@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
Hi delsim, I tried to use your django-plotly-dash to embed the newly released dash component called dash-pivottable into my django project, but in the sample snippet of the component, a sever for the app is defined by âserver=app.serverâ, which will raise an error of âAttributeError: âDjangoDashâ object has no attribute âserverââ. If I comment out that line, thereâs no error but the dash component is unable to be loaded and nothing displayed. So I want to try the âiframeâ way, but I donât understand where I can get the âhttps://dash_server_urlâ for the dash-pivottable component. You can find the dash-pivottable component here: âđŁ Dash Pivottable Releasedâ
@oneway if youâe using django-plotly-dash
then Django gets used to serve the components, so there is no embedded server.
You should just define your app, using whatever components such as the pivot table one, and then use the app with Django as described in the documentation