Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
Pass option value from select to view

I am trying to create an interactive scatterplot with options from an selectbox as a filter in Django. The problem is that the value from the select box is not passed to the view.

views.py

def dashboard(request):
    cool_data = manage_pandas(df_raw)
    posnr=cool_data['something'].unique()
    pos = request.GET.get('posi')
    
    dff = cool_data.loc[cool_data['posnr'] == pos]
    dff = dff.astype({'vnum': str})
    fig = px.scatter_matrix(dff,
    dimensions=["a", "b", "c", "d",'e'], color="g")
    fig.update_traces(diagonal_visible=False)
    sm = plot(fig, output_type="div")
    context = {
        'posnr' : posnr,
        'plot_div':sm
       
    }
    return render(request, "scatterplot/scatterplot.html", context)

scatterplot.html

<div class = "container" id = "second" style="display:true">
   
        
        <br><br>
        <select class="position">
            
            {% for pos in posnr %}
            <option value="{{ pos }}">{{ pos }}</option>
            {% endfor %}
        </select>
        
{% autoescape off %}
        {{ plot_div }}
        {% endautoescape %}        
        
<script>
$("select.position").change(function(){
    var posi = $(this).children("option:selected").val();
    var postUrl = "http://127.0.0.1:8000/scatterplot/dashboard"
        $.ajax({
            url:postUrl,
            type:'GET',
            data: {"posi":posi},
            success:function(response){console.log(response)}
            
        })
            });
            
   


</script>        
EDIT: I have added the ajax call but still something is not right , can't get the value to the view. I don't want to use form submit because I want the scatterplot to change automatically based on user input.

Thanks

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda