python - In Django's template system, how do I make it to do different things sometimes? -
{% p in posts %} <div style="width:50px;"> blah </div> {% endfor %}
however, if want div 100px 75% of time? 25% of time? randomized.
logic not go templates.
solution: write new template tag returns random number, , use width.
http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/
your template like:
{% p in posts %} <div style="width:{% myrandomtag 0 100 %}px;"> blah </div> {% endfor %}
or whatever. put required logic in python code tag.
Comments
Post a Comment