I have two variables : count, which is a number of my filtered objects, and constant value per_page. I want to divide count by per_page and get integer value but I no matter
Python does integer division when both operands are integers, meaning that 1 / 2
is basically "how many times does 2 go into 1", which is of course 0 times. To do what you want, convert one operand to a float: 1 / float(2) == 0.5
, as you're expecting. And, of course, math.ceil(1 / float(2))
will yield 1
, as you expect.
(I think this division behavior changes in Python 3.)