title: Django: Shuffle a queryset randomly and access object fields
body: <p>i have a list</p>
  
  <pre><code>[&lt;Upload: 33-bb6f5d9a98604450&gt;, &lt;Upload: 35-bb6f5d9a98604450&gt;, &lt;Upload: 30-bb6f5d9a98604450&gt;, &lt;Upload: 31-bb6f5d9a98604450&gt;, &lt;Upload: 34-bb6f5d9a98604450&gt;]
  </code></pre>
  
  <p>which has been generated by</p>
  
  <pre><code>ques = list(sorted(Upload.objects.filter(unique_id=tdetail), key=lambda x: random.random()))
  
  &lt;Upload: 33-bb6f5d9a98604450&gt;
  </code></pre>
  
  <p>here Upload is the model and <code>33-bb6f5d9a98604450</code> is the slug of model upload
  how can we extract <code>Upload</code> model values from this list</p>
  
  <p>heres my views</p>
  
  <pre><code>def platform(request,e,slug):
  article = get_object_or_404(Article,e=e)
  tdetail=get_object_or_404(test_detail,test_id=article)
  if Platform.objects.filter(user=request.user,test_key=article).exists():
      platform=get_object_or_404(Platform,user=request.user,test_key=article)
      slugs = platform.list
      for obj in slugs:
          ques = Upload.objects.filter(slug=obj.slugs)
  
       #Upload.objects.filter(slug=slugs)
  else:
      ques = list(sorted(Upload.objects.filter(unique_id=tdetail), key=lambda x: random.random()))
  
      platform=Platform()
  
  
      platform.user=request.user
      platform.test_key=article
      platform.list=ques
      platform.save()
  
  
  return render(request, 'articles/platform.html',{'ques':ques})
  </code></pre>
  
  <p>here is my model of platform</p>
  
  <pre><code>class Platform(models.Model):
  user=models.ForeignKey(User)
  test_key=models.ForeignKey(Article)
  list=models.CharField(max_length=2000)
  
  def __unicode__(self):
      return u"%s(%s)" % (self.user,self.id_apply)
  
  class Meta:
      unique_together = ('user', 'test_key',)
  </code></pre>