Fixed Python 3 compatibility bug in QuerySet.next