[Answer]-Showing random objects in Django template

1👍

You can’t put a list directly into the template like that, make_list is what you’re after.

make_list returns a list of strings, so this would work.

{% if 12|make_list|random == '1' %}
   <li><a href="{{ obj.green_link }}">Blah</a></li>
{% else %}
   <li><a href="{{ obj.blue_link }}">Blah</a></li>
{% endif %}
👤Kip

Leave a comment