views:

99

answers:

1

The Django widthratio tag takes three arguments - the top and bottom of a ratio, and a constant value.

If the ratio is greater than one, then the rendered result will be greater than the constant. For example, if your first two numbers are 6 and 3 and your constant is 100, then the rendered number would be 200, not 100.

I'm wondering if there is a way to set a ceiling for a widthratio tag so that the rendered result would not be above the constant, preferably without a new tag or filter.

A: 

What do you mean by first two numbers? Widthratio first two numbers are "this_value" and actually "max_value". So your this_value is 6, max_value is 3 and constant is 100. 6/3 = 2. 2*100=200.

If you correct the order then you will have {% widthratio 6 100 3 %} and then your width would be (6/100)*3 = 0.18.

freiksenet
This has been fixed in the question text.
jamtoday