Saturday, June 19, 2021

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


On Fri, 18 Jun 2021 at 22:43, Wai Yeung <wai@sapienml.com> 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 
            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 queryset.  I need the result in the queryset because later in the procedure, I search the queryset as follows:

queryset = queryset.filter( Q( orig_total  __icontains=search_value) )

The search_value would be a value that would rounded to 2 decimal places.

Thanks in Advance,
Wai



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b89b27f3-a11c-4b2c-8473-59420c7c3f26n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGp2JVHr3hQ03XGnOGO0i13gWhw1%3D%2Bv51BcbHAOfAb0u5V4_tg%40mail.gmail.com.

No comments:

Post a Comment