I have a FloatField which can have values like 22.33405, 33.567 etc. Now, I need to query using only upto 2 places after decimal like below
#find all objects with value equal to 22.33
ModelName.objects.filter(field = 22.33)
Is it possible to do so - can I round off or just take first 2 places after decimal?
thanks
try this
ModelName.objects.filter(field__gte=22.33, field__lt=(22.33 + 0.01))
or
ModelName.objects.filter(field__range=(22.33, 22.33 + 0.01))
range lookup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With