Skip to Content
Menu
This question has been flagged
1 Reply
2481 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
Related Posts Replies Views Activity
0
Oct 24
117
1
Apr 24
966
7
Sep 24
22447
1
Mar 24
276
0
Feb 24
413