Hassan Baig
Hassan Baig

Reputation: 15824

Extending base.html conditionally, in Django template

Based upon whether a custom-defined context variable {{ state }} is true or false, I want to extend a different flavor of base.html in a Django template.

What's the Django template code to make this happen?

I'm trying: {% extends state|yesno:"base1.html;base2.html" %} but unsure whether this is correct.

Upvotes: 3

Views: 604

Answers (1)

gtlambert
gtlambert

Reputation: 11961

You are almost there - you just need to replace your semi-colon ; with a commma ,:

{% extends state|yesno:"base1.html,base2.html" %}

Upvotes: 2

Related Questions