Incremement Page Hit Count in Django

Posted by Andrew C on Stack Overflow See other posts from Stack Overflow or by Andrew C
Published on 2009-03-07T22:42:05Z Indexed on 2010/03/22 18:21 UTC
Read the original article Hit count: 284

Filed under:
|
|

I have a table with an IntegerField (hit_count), and when a page is visited (ie. http://site/page/3) I want record id 3 'hit_count' column in the database to increment by 1.

The query should be like: update table set hit_count = hit_count + 1 where id=3

Can I do this with the standard Django Model conventions? Or should I just write the query by hand?

I'm starting a new project, so I am trying to avoid hacks. We'll see how long this lasts!

Thanks!

© Stack Overflow or respective owner

Related posts about django

Related posts about django-models