[web2py] Re: How to format the result of a sum()

2017-04-01 Thread 黄祥
of course you can do it in controller *e.g.* def index(): import locale sum = db.log.severity.sum() sum_result = db().select(sum).first()[sum] # float sum_result_formatted = DIV('%s' % (locale.format("%.2f", sum_result, grouping = True) ) ) # int #sum_result_formatted = DIV('%s' % (format(sum_resu

[web2py] Re: How to format the result of a sum()

2017-04-01 Thread mkerins
Thanks for this, but is there no way to apply this formatting in the controller? My views are very simple, with tables being rendered simply with {{=tbl}}, so unless I'm missing something, I don't think I really have any way to apply the DIV as you suggested. Thanks. On Friday, March 31, 2

[web2py] Re: How to format the result of a sum()

2017-03-30 Thread 黄祥
pls try in views *e.g.* *for float :* {{=DIV('Rp. %s' % (locale.format("%.2f", total_sum_sales, grouping = True) ) ) }} *for integer* {{=DIV('%s' % (format(total_sum_sales, ",d").replace(",", ".") ) ) }} best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentat