[Python] Django - How can i resize the svg in the html template

Discussão em 'Python' iniciado por Stack, Fevereiro 24, 2025.

  1. Stack

    Stack Membro Participativo

    I just created a matplot figure from a csv in django (line graph) and rendering it to the html template and I can't modify its dimensions

    imgdata = io.StringIO()
    fig.savefig(imgdata, format='svg')
    imgdata.seek(0)
    data = imgdata.getvalue()
    return data
    data = isolate(selected_loc)
    return render(request, 'hello.html', {'data': data, 'locations' : list(locations)})




    html template

    <div class="figure" style="">{{ data|safe }}</div>


    i tried styling the div in css

    .figure {
    width: 40%;
    height: 500px;
    }


    and it doesnt working only the div container expands but not the svg that just rendered

    enter image description here

    Continue reading...

Compartilhe esta Página