model1:
class Tag(models.Model):
text = models.CharField(max_length=255, null=True, blank=True, unique=True)
model2:
class TagConnect(models.Model):
tag = models.ForeignKey("category.Tag", on_delete=models.CASCADE, null=True, blank=True)
created = models.DateTimeField(auto_now_add=True)
I want to get top 5 Tag object by count of TagConnect object that has created in recent 24 hours.
The more TagConnect object exists, the tag is more likely on high priority.
If tag "rabbit" has 2 TagConnect in 24 hours and "horse" has 10 TagConnect but those are not in 24 hours, "rabbit" has more high priority.
Maybe it will be like..
Tag.objects.order_by(tag_connect_in_24hours)[:5]
How to do this?