GithubHelp home page GithubHelp logo

Comments (2)

wlwatkins avatar wlwatkins commented on May 8, 2024

I don't know if this helps, but it's the teared down of my script for downloading a file.
download_file() is called by reverse('download_file') in the layout html via the urls.py. Here is the views.py and dash_app.py

views.py

from django.shortcuts import render
from django.http import HttpResponse

def homePage(request, **kwargs):
    request.session.flush

    context = {}
    dash_context = request.session.get("django_plotly_dash", dict())
    request.session['django_plotly_dash'] = dash_context
    from . import dash_app

    return render(request, template_name='index.html')

def download_file(request, **kwargs):
     var_1 = request.session['django_plotly_dash']["input_1"]
     var_2 = request.session['django_plotly_dash']["state_1"]

     # CREATE FILE FROM var_1 and var_2 e.g. csv etc...

    return HttpResponse(file)

dash_app.py

@app.expanded_callback(
    output = Output('output_div','children'),
    inputs = [Input('input_1','value')],
    state = [State('state_1', 'value')]
    )
def function_A(input_1, state_1, *args, **kwargs):

    kwargs['session_state']['input_1'] = input_1
    kwargs['session_state']['state_1'] =state_1

from django-plotly-dash.

GibbsConsulting avatar GibbsConsulting commented on May 8, 2024

PR #114 contains an example of using session state

from django-plotly-dash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.