You can use Django template's "with" statement to calculate values. This is an elegant approach as it removes the need for many "if" statements.
Example: Put a border around a specific kind of image on a page.
Using the conditional style:
Using the calculation style: