[Fixed]-Why is a float digit rounded in django list_display

1👍

As selchuk mentioned, if you do float(self.flat_price) / self.flat_prediction_price that will return you the floated result (and you can round from there).

What’s happening with what you’re doing now is that you’re dividing an int by an int, which will give you an int result. You’re then rounding after you have that int result, which won’t round how you’re wanting it to round since it is already just 0. By diving a float by int (or can convert both to float) you’ll get back a float result and can round that result.

Leave a comment