title: Randomize a Django queryset once, then iterate through it
body: <p>I'm writing an app that allows people to compare different pairs of hashtags. </p>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>class Competitors(models.Model):
      tag1 = models.ForeignKey('Hashtag', related_name='+')
      tag2 = models.ForeignKey('Hashtag', related_name='+')
      votes = models.PositiveIntegerField(default=0, null=False)
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre><code>def compare_hashes(request, i=None):
      i = i or 0
      try:
          competitors = Competitors.objects.order_by('?')[i]
      except IndexError:
          return render(request, 'hash_to_hash.html',
              {'tag1': '', 'tag2': '', i: 0, 'done': True})
  
      if request.method == 'POST':
          form = CompetitorForm(request.POST)
          if form.is_valid():
              if "yes" in request.POST:
                  competitors.votes += 1
                  competitors.save()
          i += 1
          return render(request, 'hash_to_hash.html',
                    {'tag1': competitors.tag1, 'tag2': competitors.tag2, i: i, 'done': False})
  
      else:
          return render(request, 'hash_to_hash.html',
                    {'tag1': competitors.tag1, 'tag2': competitors.tag2, i: i, 'done': False})
  </code></pre>
  
  <p>What I want to do is, per visitor, randomize the ordering of the Competitors objects, and then iterate through that randomized list.</p>
  
  <p><strong>Questions:</strong></p>
  
  <ol>
  <li>What's a better way of randomizing things besides o<code>bjects.order_by('?')</code>? I'm using MySQL, and I've seen some things on here about how <code>order_by('?')</code> + MySQL = SLOOOOOOOW. There were a couple of suggestions given, and I could easily implement something (I was thinking something along the lines of <code>random.shuffle(Competitors.objects.all())</code>), but I'm not sure where I'd put it, which leads me to my second question...</li>
  <li>How do I make sure the randomization only happens once? I don't want to bore people by making them review the same pairs over and over again, and I don't want to throw off my results by having some pairs randomly showing up more than once. I want everybody to see the same list, just in different orders.</li>
  </ol>
  
  <p>I suspect the answer lies in a Manager class, but, really, this all boils down to my lack of knowledge about what Django calls when.</p>
  
  <p><em>(I'm also having a problem where the results don't seem to be getting saved to my db, but that's a different, probably more easily solved, issue.)</em></p>