title: Custom filter for Django querysets
body: <p>Good day, I have a problem: I have a model with some fields. </p>
  
  <pre><code>class Gallery(models.Model):
      image = models.FileField(upload_to='gallery/')
      status = models.BooleanField()
      type = models.BooleanField()
  </code></pre>
  
  <p>I used this model for storing gallery image in masonry grid. This grid is fixed and I need to get 12 random image, this is easy to do. </p>
  
  <pre><code>gallery = Gallery.objects.all().order_by('id','pk').order_by('?')[: 12];
  </code></pre>
  
  <p>But 5 of them should have True type, and 7 others - False. And I'll be insanely happy if it'll be able to custom an order in this queryset, for example, True means horizontal picture(h), False - vertical[v]. I want to get an order like this [v,h,h,h,v,v,v,h,h,v,v,v]</p>