Re: Using ORM to retrieve values (REAL) from SQLite database to round to 2 decimal places

2021-06-21 Thread Lalit Suthar
That's great the way you found the workaround :D We can also try writing raw sql queries to use sql functions https://docs.djangoproject.com/en/2.2/topics/db/sql/#executing-custom-sql-directly But that has some security issues since we have to pass a search parameter into it. On Mon, 21 Jun 2021

Re: Using ORM to retrieve values (REAL) from SQLite database to round to 2 decimal places

2021-06-21 Thread Wai Yeung
Thanks for the quick response Lalit, Django "Round" rounds to the nearest integer whereas SQLite "round" allows you to pass in a second parameter to to round "rounded to Y digits to the right of the decimal point" (https://sqlite.org/lang_corefunc.html#round). That said, since Django "Round" does

Re: Using ORM to retrieve values (REAL) from SQLite database to round to 2 decimal places

2021-06-19 Thread Lalit Suthar
this can help https://docs.djangoproject.com/en/2.2/ref/models/database-functions/#round On Fri, 18 Jun 2021 at 22:43, Wai Yeung wrote: > Hello, > > To be able to get a REAL value from a SQLite database rounded to 2 decimal > places, I had to use the following RAW SQL query: > > SELECT >

Using ORM to retrieve values (REAL) from SQLite database to round to 2 decimal places

2021-06-18 Thread Wai Yeung
Hello, To be able to get a REAL value from a SQLite database rounded to 2 decimal places, I had to use the following RAW SQL query: SELECT printf("%.2f", round(orig_total,2)), FROM final_billing_tbl I would like to be able to duplicate the functionality of the in ORM to create a q