Skip to content

DirectlineDev/django-hitcounter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Hitcounter

image

image

image

image

image

About

Pretty simple hit counter for Django ORM objects. It collects hits for any django model objects per date.

Requirements

  • Python 2 & 3
  • Django 1.7+

Installation

  1. Install it using pip (coming soon):
pip install djangohitcounter

or add django_hitcounter to your Python path

  1. Add the django_hitcounter app to your INSTALLED_APPS:
# settings.py
INSTALLED_APPS = (
  ...,
  'django_hitcounter',
  ...
)

Usage

Usage is pretty simple too.

from django_hitcounter.models import Counter
from datetime import datetime, timedelta


obj = SomeModel.objects.get(pk=1)  # get some django object

Counter.hit(obj)  # register hit
Counter.hit(obj, amount=2)  # register 2 hits
Counter.hit(obj, date=datetime.today().date() - timedelta(days=1))  # register hit on yesterday date

Counter.objects.for_model(obj)  # get all counter records for our object
Counter.objects.for_model(obj, total=True)  # get total hits count for object

License

This software is distributed under the Apache License Version 2.0

About

Pretty simple hit counter for Django ORM objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages