I don't think that will work. Note, the {{extend}} and {{include}}
directives are not Python code and are processed before any of the Python
code is executed. You can do a conditional {{include}}, but technically in
that case both included views will be inserted in the view code, with only
one getting executed (based on the condition). I don't think this will work
properly with {{extend}}, though. An alternative is to use a conditional
variable assignment to set the extended layout:
{{layout = 'layout1.html' if condition else 'layout2.html'}}
{{extend layout}}
However, in that case you will not be able to bytecode compile the view
because the value of "layout" is not determined until runtime, but
compiling requires the value be known at compile time.
Anthony
On Sunday, October 14, 2012 8:52:03 AM UTC-4, qwer qwer wrote:
>
> is it not possible?
> {{if condition:}}
> {{extends 'layout1.html'}}
> {{else:}}
> {{extends 'layout2.html'}} thanks
>
--