Pierre de LESPINAY
Pierre de LESPINAY

Reputation: 46178

Django - Template chain tags

I would like to use a firstof in a with like

<div>
  {% with variable = firstof variable1 variable2 %}</div>
  {{ variable }}
  {% endwith %}
</div>

But of course I'm getting

u'with' received an invalid token: u'variable1'

Is there another way to use these 2 tags together ?

Upvotes: 1

Views: 1334

Answers (1)

Sam Starling
Sam Starling

Reputation: 5378

You can't assign firstof to a variable like this, sadly (see this thread on django-users). You'd need to write your own custom template tag.

Upvotes: 1

Related Questions