Related models:
models.py
class Entry(models.Model):
...
class EntryView(models.Model):
entry = models.ForeignKey(Entry)
dt_clicked = models.DateTimeField(auto_now_add=True)
ip = models.CharField(max_length=15, db_index=True, blank=True)
host = models.CharField(max_length=64, db_index=True, blank=True)
referer = models.CharField(max_length=64, db_index=True, blank=True)
def __unicode__(self):
return "%s -> %s" % (self.ip, self.entry.headline)
I guess I could do something like this:
views.py
...
popular = Entry.articles.values('ip').annotate(Count("entry_views__id")).order_by()
...
But I can't see how this would work since there is no field for EntryView in Entry.