[Answer]-Dynamically populate template from two lists

1👍

You can zip the lists in your view,

current_task_resources = zip(current_task_resources_types, current_task_resources_names)

then loop through the zipped list in your template

"task": [
    {% for type, name in current_task_resources %}
        {"type": "{{ type }}", "url": "{{ names }}"},
    {% endfor %}
]

In Python 2, itertools.izip may improve performance if the lists are long.

Leave a comment