Hi. The site makes use of 2 objects - articles and blogs. Every time an article or blog is viewed, a related counter should increase by one.
The idea is to have a "top ten" application that measures the "popularity" of the articles and entries.
Because I'm using more than one object, I would like the Tracker model to use a genericForeignKey to the related objects.
#models.py
class Tracker(models.Model):
count = models.PositiveIntegerField(default=1)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
def hit(self):
self.count += 1
I would like to write a decorator that wraps a view function, but it might not be necessary.
Thanks