I have a database model like this:
class RssNewsItem(models.Model):
title = models.CharField(max_length=512)
description = models.TextField()
image_url = models.CharField(max_length=512)
published = models.DateTimeField(auto_now=True)
url = models.CharField(max_length=512, default='')
author = models.CharField(max_length=128, default='')
I would like to 'promote' a certain author by selecting 3 of its news-items and 7 items from other authors (making a list of 10 news-items) and order them by -published
. The position of the promoted news-items on the list is irrelevant. Numbers are also not important. It just have to be that promoted news-items cover 30% of the list.
Let's suppose that I want to promote 'author1' and I have 6 total authors in my website.
Is this possible with Django? (I would like to avoid iterating through lists or querysets)