Fixed ZeroDivisionError with empty querysets.

Regression introduced by 50a025ce3534920235d0679fd0e72c010645a093