Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda