在Django查询集中提供与给定id列表匹配的提升分数

时间:2018-06-11 10:26:15

标签: django django-queryset recommendation-engine

给定一组ID,

class Article(model.Model):
    hotness = FloatField()
    content = TextField()
    created = DateField()

    @property
    def calculate_hotness(self):
        return (self.created.replace(tzinfo=None)-datetime(1970,1,1)).total_seconds() 

# The hotness field is updated by a cronjob hourly.

recommended_ids = [1,2,3,4]

Article.objects.order_by('-hotness').???

我想在recommended_ids中给出带有ID的文章,得分为1.5倍。

0 个答案:

没有答案