List in HTML table separated by category

0

I'm in a development using Python and Django and as IDE the pycharm.

I have a list coming via Rest by mobile, under 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 descending order by TIME. (Each category separated by an HTML TABLE)

How to do it?

    
asked by anonymous 20.08.2018 / 18:50

2 answers

0

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

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

After all the players who are in the spfc team with the time descending

    
22.08.2018 / 03:06
0

Do 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 not answer without a better example of your input and an explanation of what you want. But most of all, we have to know what you are already doing, what are the errors found, etc.?

    
23.08.2018 / 19:14