title: How to pull a random record using Django's ORM?
body: <p>I have a model that represents paintings I present on my site. On the main webpage I'd like to show some of them: newest, one that was not visited for most time, most popular one and a random one. </p>
  
  <p>I'm using Django 1.0.2.</p>
  
  <p>While first 3 of them are easy to pull using django models, last one (random) causes me some trouble. I can ofc code it in my view, to something like this:</p>
  
  <pre><code>number_of_records = models.Painting.objects.count()
  random_index = int(random.random()*number_of_records)+1
  random_paint = models.Painting.get(pk = random_index)
  </code></pre>
  
  <p>It doesn't look like something I'd like to have in my view tho - this is entirely part of database abstraction and should be in the model. Also, here I need to take care of removed records (then number of all records won't cover me all the possible key values) and probably lots of other things.</p>
  
  <p>Any other options how I can do it, preferably somehow inside the model abstraction?</p>