In Django's template system, how do I make it to do different things sometimes?

{% for p in posts %}
    <div style="width:50px;">
{% endfor %}

However, what if I want the div to be 100px 75% of the time? 25% of the time? Randomized.


Logic does not go into templates.

Solution: write a new template tag that returns a random number, and use that for the width.

Your template would then look like:

{% for p in posts %}
    <div style="width:{% myrandomtag 0 100 %}px;">
{% endfor %}

Or whatever. Put your required logic in the python code for the tag.

random filter should do the thing

Need Your Help

Launching app from root account

objective-c cocoa launchd

I am developing a Cocoa GUI app that has an Objective-C daemon. The daemon is launched by LaunchDaemon, the GUI is launched using loginItems for each user.

Change the Width of a merged Table Cell in VBA (Word 2010)

vba word-vba word-2010

In MS Word 2010, changing the width of a merged cell is a bit tricksy.

Flyspell: is it possible to ignore words based on pattern?

emacs spell-checking

I would really like to disable flyspell checking of camel-cased words - most of the times they aren't valid English. Is there any way to do that?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.