Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
Django looping through items not showing

Hi I am looping through items being passed through the context but nothing is showing.

This is the data I have:

{"error":[],"result":{"USDT":"60000.00000000","CHZ":"13773.0349000000","ZRX":"0.0000000000","ZUSD":"67787.8285","DOT":"0.0000000000","COMP":"0.0000034600","ENJ":"257.6815000000","ADA":"2473.80445621","XXDG":"17006.92601155","ALGO":"32063.69514500","XXBT":"0.0000012880","SUSHI":"172.4585500000","SOL":"1133.3543869800","DASH":"0.5104491200","LINK":"144.2407000000","ATOM":"151.26763831","XXLM":"6926.27220000","XXRP":"0.00000000","XETH":"14.5877343640","TRX":"923.80015900","KNC":"0.0000000000","BAL":"0.0000000000","XLTC":"11.4923900000","KSM":"24.7142610000","SC":"0.0000000200","OCEAN":"652.6077000000","MATIC":"1838.9295772000","AAVE":"83.6218990800","ZGBP":"30622.0790","XZEC":"0.0000073100"}}

It is passed in my context like this:

def kraken(request):
    """ A view to return kraken page """
    context = {
        'api_reply': api_reply,
    }
    return render(request, 'home/kraken.html', context)

And inside my template I have this:

{% for k, v in api_reply.items %}
<tr>
  <td>{{ k }}</td>
  <td>{{ v }}</td>
</tr>
{% endfor %}

I have no errors showing but it is not displaying, any help would be great thank you.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The items are stored in the result subelement, you thus should enumerate over api_reply.result.items, not api_reply.items:

{% for k, v in api_reply.result.items %}
<tr>
  <td>{{ k }}</td>
  <td>{{ v }}</td>
</tr>
{% endfor %}

Furthermore you need to convert the JSON blob into Python objects, for example with:

import json

def kraken(request):
    """ A view to return kraken page """
    context = {
        'api_reply': json.loads(api_reply),
    }
    return render(request, 'home/kraken.html', context)
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda