I think you can get some better performance here by using an __in lookup. In other words using:

return self.filter(id__in=random_indexes)

It's also just a bit simpler