Skip to content Skip to sidebar Skip to footer

Django Templates Display List

This is sort of a follow up to a previous question, but I'll repost all of my code here- I want to display the contents of a list in Django and I'm using this in my template - &l

Solution 1:

The problem is because mistyping. Some spaces are in the wrong place. use this

{% for author in authors %}
    <li>{{ author|safe }}</li>
{% endfor %}

Solution 2:

The cleanest way to display a list in django is:

{{ var|unordered_list }}

You can also add safeif you want to display html:

{{ mylist|safe|unordered_list }}

NOTE: on the last code i'm not 100% sure if safe is before or after unordered_list

Post a Comment for "Django Templates Display List"