Closed rage2000 closed 10 years ago
On slideshows/views.py
line: 57
count = queryset.aggregate(count=Count('id'))['count'] random_index = random.randint(0, count - 1) return queryset.all()[random_index]
if count == 0 we call randint with (0, -1), and raise ValueError: empty range for randrange() (0,0, 0)
If count == 0 we could return None:
count = queryset.aggregate(count=Count('id'))['count'] if count == 0: return None random_index = random.randint(0, count - 1) return queryset.all()[random_index]
Ok thanks, this is done in commit 14c0e3f with 0.8.1.1 release on Pypi.
Note than i return an empty list instead of None value.
On slideshows/views.py
line: 57
if count == 0 we call randint with (0, -1), and raise ValueError: empty range for randrange() (0,0, 0)
If count == 0 we could return None: