I want to display the cost of the share in Quote tab using the "usd" function defined in helpers.py. I've tried adding app.jinja_env.globals.update(usd=usd)in application.py and then calling the function in quoted.html as {{ usd(rows.price) }} where rows is the dictionary returned by the lookup function. Please suggest a way to do so.

Update: It worked. Had another small bug. Adding the global env part solves the problem.

  • Thank you this really helped me. Jul 3, 2017 at 21:56
  • Thanks it helped me so much . Jan 29, 2019 at 18:39
  • @AdityaGaikwad @dumbitdownjr @AmilaRose Although setting the function as global worked. But it would be useful to understand, how it actually works(without tinkering with setting the function as globals). Functions can be used as jinja filters in html pages. Simply do {{rows.price | usd()}}
    – C--
    Apr 12, 2021 at 6:46
  • @C-- thank you very much!
    – j-fl0
    Jun 23, 2021 at 18:38


You must log in to answer this question.

Browse other questions tagged .