1
I’m making a system using Python and Django. At one point, I’m showing a table with database information. Follow my html:
<tbody>
    {% for oportunidade in all_oportunidades %}
    <tr class="clickable-row" data-href="{% url 'crm2:editaroportunidadeview' oportunidade.id %}">
    <td>{{oportunidade.id}}</td>
     <td>{{oportunidade.situacao}}</td>
     <td>{{oportunidade.cliente}}</td>
     <td>{{oportunidade.categoria|default_if_none:""}}</td>
     <td>{{oportunidade.data_abertura|default_if_none:""}}</td>
     <td>{{oportunidade.valor|default_if_none:""}}</td>
     {% endfor %}
     {%else%}
     {%endif%}
     </tbody>
However, in the table, in the fields of situacao and categoria is being shown the IDS of the same and not its content. For example, appears like this in the table;
ID | Cliente | Situação | Categoria
-----------------------------------
 1 | Marcos  |    2     |    1
But I want you to show up like this:
ID | Cliente | Situação | Categoria
-----------------------------------
 1 | Marcos  |Cancelado |  Venda
In models.py, I defined situacao thus:
SITUACAO_OPCOES = (
(u'0', u'Concluída com sucesso'),
(u'1', u'Cancelado'),
(u'2', u'Em andamento')
)
situacao = models.CharField(max_length=1, choices=SITUACAO_OPCOES, default=2)
categoria in the same way.
How do I display the value, not the id?
Just to add some useless information, you don’t have to do the
{% if all_oportunidades %}. 'Cause an empty list will crossforand will not do anything at all. : D– fernandosavio