Improving python-generated table visuals with Django and bootstrap

Asked

Viewed 41 times

0

I have a table that I Gero through the python prettytable, it generates a variable that contains a table, I send this variable to the Jango template and it is all disfigured, could I improve her look? If you don’t have another way to generate this table on the screen?

follows my codes and table images.

x = PrettyTable(["Horario", "Ligado", "Desligado"])
    x.align["Horario"] = "2"
    x.align["Ligado"] = "2"
    x.align["Desligado"] = "r"
    x.padding_width = 1
    z=0
    while z < len(teste4):
        x.add_row([teste4[z], tabela1[z], tabela2[z]])
        z = z + 1
    print (x)

Generates the table:

inserir a descrição da imagem aqui

But on the screen when I play it for the tamplate with bootstrap gets like this:

inserir a descrição da imagem aqui

Using just that code, I think that’s the mistake:

{% extends 'base.html' %}

{% block main %}

Edit


<form method="POST">
    {% csrf_token  %}

    <label for="descricao">Data Inicial:</label>
    <input id="descricao" type="text" name="descricao" value="{{ descricao }}" class="form_datetime" /><br>
    <script type="text/javascript">
        $(".form_datetime").datetimepicker({ format: '03/01/19 08:00' });
    </script>
    <label for="descricao2">Data Final:</label>
    <input id="descricao2" type="text" name="descricao2" value="{{ descricao2 }}" class="form_datetime" /><br>
    <script type="text/javascript">
        $(".form_datetime").datetimepicker({ format: '03/01/19 09:00' });
    </script>
    <input type="submit">

    {% if descricao != None %}
    <br><br>
        <p>

            Data Inicial: {{ descricao }}<br>
            Data Final: {{ descricao2 }}<br>
            Tabela: {{ x.get_html_string() }}

        </p>
    {% endif %}

    <a href="{% url 'graficos' %}" class="btn btn-primary">Grafico2</a>
    <a href="{% url 'tela_graficos' %}" class="btn btn-primary">Grafico</a>
</form>
{% endblock %}
  • Place the structure of your HTML that receives the data, it will help to answer you

  • The way the terminal displays text is different from the way HTML does it. There is a way for you to display like this in HTML, but since you are using HTML, it would not be better to use HTML itself <table>?

  • @hugocsl put all the html code, on the comment of the Anderson, already tried and there appears no information

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.