Skip to main content

Basic app that allows you to track the number of hits/views for a particular object.

Project description

Django-Cached-HitCount
===============

Basic app that allows you to track the number of hits/views for a particular
object.

All hits are stored in memcache until persisted to database.

As the hits are stored in cache there are no DB queries/inserts/updates on each request.

Adding hits is done via an ajax call so that app can still be used on cached views.

You can persist the hits to DB using celery and the `persist_hits` periodic task or use the `persist_hits` management command.

python manage.py persist_hits

hitcount_example app shows how to use app, by using `get_hit_count_javascript_template` and `get_hit_count` template tags.

Available settings are:

* HITCOUNT_CACHE -The CACHES setting dict key to use for caching hits (default is `cached_hitcount`)
* HITCOUNT_CACHE_TIMEOUT - How long in seconds should the hits be cached for before persisted (default is `600`)
* HITCOUNT_IP_CACHE_TIMEOUT - How long in seconds should the black list ip addresses be cached for (default is `86400` seconds = 1 day)
* HITCOUNT_PERSIST_SCHEDULE - How often should the hits be persisted (default is `15` minutes)
* HITCOUNT_IP_CACHE - key name to use for caching the blacklist ip addresses (default is `hitcount__blacklistip`)
* HITCOUNT_EXCLUDE_IP_ADDRESS - Whether or not you want to exclude some ip addresses (default is True)
* HITCOUNT_EXCLUDE_BOTS - Whether or not you exclude bots (default is True)
* HITCOUNT_LOCK_KEY - key name to use for locking when persisting hits to DB

Also a gargoyle switch `cached_hitcount` to switch on/off all hit counting (default is True)

This app was very much inspired by <http://damontimm.com/code/django-hitcount/>


Installation:
-------------

Simplest way to formally install is to run:

./setup.py install

Or, you could do a PIP installation:

pip install -e git://github.com/philroche/django-cached-hitcount.git#egg=django-cached-hitcount

Or using PyPi

pip install django-cached-hitcount

Copyright:
-------------

This package is © 2014 Philip Roche, released under the terms of the GNU GPL v3 (or at your option a later version).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-cached-hitcount-0.2.4.tar.gz (12.1 kB view details)

Uploaded Source

File details

Details for the file django-cached-hitcount-0.2.4.tar.gz.

File metadata

File hashes

Hashes for django-cached-hitcount-0.2.4.tar.gz
Algorithm Hash digest
SHA256 7e605ab1fbfe25f5e759f952c918e5227ecfdded0eecc96b88060a576af27657
MD5 6bbdf65f528c84ba8043c6cbfcaeb86c
BLAKE2b-256 e78e8e3c78e54d81f18ab7c5960ab3504a6028db3ce13335b537be30f5c6da67

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page