Good day, I have a problem: I have a model with some fields.
class Gallery(models.Model):
image = models.FileField(upload_to='gallery/')
status = models.BooleanField()
type = models.BooleanField()
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.
gallery = Gallery.objects.all().order_by('id','pk').order_by('?')[: 12];
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]