Random string in template django
问题 Is there any way to have a random string in a django template ? I would like to have multiple strings displaying randomly like: {% here generate random number rnd ?%} {% if rnd == 1 %} {% trans "hello my name is john" %} {% endif %} {% if rnd == 2 %} {% trans "hello my name is bill" %} {% endif %} EDIT: Thanks for answer but my case needed something more specific as it was in the base template (wich I forgot to mention sorry ) . So after crawling google and some doc I fall on context