This question has been flagged
1 Reply
2375 Views

I am creating a web page, that uses expressions passed to the template, using request.render, in this way:

return request.render('mymodule.mypage', data)

"data" is a big dictionary, and some of the keys, not always exist. I need to use a safe method, preventing to have error 500 in the qweb evaluation of the expressions. Something like:

<t t-esc="values['value1'] or ''"/>

or using filters, like in Jinja2.

How should be the best way?

Avatar
Discard
Best Answer

Hi, You can always check using t-if condition like

<t t-if='values and values['key']'>
<statements></statements>
<t/>


Avatar
Discard