← Back2022-06-05Django objects with JavaScriptAssign javascript variable from django objects like so. {% block javascript %} <script> const todos = [ {% for todo in object_list %} { id: "{{ todo.id }}", name: "{{ todo.name }}", }, {% endfor %} ]; todos.forEach((todo) => { // ... }) </script> {% endblock javascript %}