I have the following models
class Dishes(models.Model):
name = models.CharField(max_length=40, unique=True)
date_added = models.DateTimeField(auto_now_add=True)
#increment/decrement with upvote added or removed
count_votes = models.IntegerField(blank=True, null=True, default=0)
class Upvotes(models.Model):
dish = models.ForeignKey(Dishes)
user = models.ForeignKey(User)
date_added = models.DateTimeField(auto_now_add=True)
I have 3 sorts for dishes, the first 2 are by date_added & count_votes, which are easy to implement with dishes.order_by('-count_votes') and dishes.order_by('-date_added'), the third sort is a "trending sort" which I essentially want to be a sort that ranks dishes as a function of upvotes over time, any idea how I could go about doing this?