I’m trying to access to my django context from my views.py to my index.html page but something wrong and I need help.
My context from django called in my html template is working fine with:
{% for i in links %}
<li><a>{{i.id}}; {{i.sequence}}; {{i.category}};{{i.link}}; {{i.description}}; {{i.image}}</a></li>
{% endfor %}
out of that give me:
2; 0; OUTILS DU QUOTIDIEN – DIVERS;https://safran.fabriq.tech/login; La solution tout-en-un pour le QRQC Digitalisé ! Détectez, escaladez, résolvez vos problèmes plus rapidement et améliorez votre performance.; Logos/Fabriq_0ER4lsy.png
3; 0; OUTILS DU QUOTIDIEN – DIVERS;https://improve.idhall.com/; Improve est la plateforme collaborative de Safran pour piloter toutes les initiatives de progrès du Groupe (de l’idée au projet d’amélioration).; Logos/Improve_lFlB5pY.png
4; 0; OUTILS DU QUOTIDIEN – DIVERS;https://portal.bi.group.safran/reports/powerbi/REPORTS/Safran%20Aircraft%20Engines/Develop/Innovation-Participative-SAE/IP-FULL-SAE?rs:Embed=true; PowerBI IP Safran Aircraft Engines.; Logos/Gestor_gVEU0RR.png
but in my js:
<script>
var linksData = '{{links}}';
for(let j=0;j< linksData.length;j++)
{
document.writeln('<p class="card-text">"'+String(linksData[j].category)+'"</p>');
}
</script>
give me :
"undefined"
"undefined"
"undefined"
"undefined"
"undefined"
"undefined"
"undefined"
"undefined"
"undefined"
"undefined"
"undefined"
"undefined"
"undefined"
...
My attempt was also with
var linksData = JSON.parse('{{links|escapejs}}');
but still not working and return nothing, could you help me please?
Thanks a lot
Philippe