List in HTML table separated by category

Asked

Viewed 111 times

0

I am in a development using Python and Django and as IDE pycharm.

I have a list coming via Rest by mobile, with the name 'Athletes', and comes with the columns "name", "category", "time".

I would like to list these athletes in an HTML TABLE, but separated by category and order decreasing by TIME. (Each category separated by an HTML TABLE)

How to do?

  • 1

    What would be "separated by an html table"? Each category in a table?

  • 1

    You need to put some of the code and the data ofmato you have in hand - you can not answer the question like this. Put the view code you have, and an example with some rows of data you have to display.

2 answers

0

You want an output like this?

<table class="tg">
  <tr>
    <th class="tg-0lax">nome</th>
    <th class="tg-0lax">categoria</th>
    <th class="tg-0lax">tempo</th>
  </tr>
  <tr>
    <td class="tg-0lax">João</td>
    <td class="tg-0lax">futebol</td>
    <td class="tg-0lax">20</td>
  </tr>
  <tr>
    <td class="tg-0lax">Maria</td>
    <td class="tg-0lax">basquete</td>
    <td class="tg-0lax">40</td>
  </tr>
  <tr>
    <td class="tg-0lax">José</td>
    <td class="tg-0lax">volei</td>
    <td class="tg-0lax">30</td>
  </tr>
</table>


| nome  | categoria | tempo |
|-------|-----------|-------|
| João  | futebol   | 20    |
| Maria | basquete  | 40    |
| José  | volei     | 30    |

But we need more information. You can’t answer without a better example of your input and an explanation of what you want. But mostly, we have to know what you are already doing, what errors found, etc?

0

When you bring data from the database you should set it as order_by desc. Ex:

Atletas.objects.filter(categorias='spfc').order_by('-tempo')

Bring all players who are on the spfc team with decreasing time

Browser other questions tagged

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