class PaintingManager(models.Manager):

    def random(self):
        count = self.aggregate(count=Count('id'))['count']
random_index = randint(0, count - 1)
return self.all()[random_index]
How to pull a random record using Django's ORM?