Closed wlwatkins closed 5 years ago
Callbacks are for determining values used inside of the dash app, not for directly providing HTML content. Using the example from the plot.ly link as a starting point, you probably want to leave the Dash layout part unchanged (up to the actual download URL) and just add the download_url function as a normal Django view. The latter you can probably achieve with very little effort using the django rest framework or similar.
Ok I figured it out. The doc infers one can use session state to store JSON in the user session which can then be used in Django. I did struggle to get to pass the data. The doc should be, in my opinion, detailed for use in such an example. For instance, by giving a code snippet.
Thats a good observation, thanks. Created #100
Issue #100 now merged as PR #114
Is there a way to serve csv files from the dash app. Similarly to what can be seen in this link in Flask https://community.plot.ly/t/allow-users-to-dowload-an-excel-in-a-click/9410 That is :
@app.server.route('/download_excel/') def download_excel(): ''' prepare excel or csv file ''' return send_file(...)
Indeed, if I do a
redirect()
from django, I get a successful post from the server but I don't get redirected:@app.callback( Output('hidden-output', 'children'), [Input('download_csv', 'n_clicks')]) def redirect_btn(n_clicks): to_redirect() return 'res'
def to_redirect(): return redirect('https://example.com/')
am I missing something? Hope there's enough info in this post