Is there a way to have a random string in a django template?
I would like several lines to be displayed randomly:
{% 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 the answer, but my case needed something more specific, as it was in the base template (which I forgot to mention). Therefore, after scanning Google and some documents, I find myself on an article with a context processor that did this work, I found it a bit “hacked” anyway just to create a random number ...
here is the blog page: http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/
The template tag is not a trick (or I did not find it) as it returns a tag that cannot be translated as I recall (see blocktrans doc)
( -?), , , .