I'm interested in what the community suggests on this topic, as it's
something I'd like to implement as well. However, one word of advice if
you're using MySQL and its Query Cache... try to keep the "views"
column outside of your models table since updating that table on every
hit would basically make the query cache for that table irrelevant. As
I understand it, the Query Cache for a query is wiped if the table that
is used in the cached query is changed after the query is cached. In
this case the table would be changed on every load, so the query would
never be cached. So perhaps a generic table like 'views' could be used
with the GenericForeignKey setup that Django uses (like for "tags" or
"comments"). This could possibly allow queries on that model to be
cached (unless the query is hitting the "views" table in a join for
every object load/hit).
Even if no cache benefit can be gained, I like the ability to add a
"views" property to ANY object that you please just by setting up a
Generic foreign key though, it's much easier to add that functionality
to any object without having to modify your DB schema at all.
Jay
Any suggestions on how I could track how many times an object has
loaded and/or been clicked?
I mean, obviously in my model I'd need something like
class Item(models.Model):
views = IntegerField()
but how would I update views when Item was loaded on a page?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---