Skip to main content

Pretty simple hit counter for Django ORM objects

Project description

https://badge.fury.io/gh/DirectlineDev%2Fdjango-hitcounter.svg https://travis-ci.org/DirectlineDev/django-hitcounter.svg?branch=master https://badge.fury.io/py/djangohitcounter.svg

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

TODO

  • tests and autotests on CI

  • badges: pypi (ready), build (ready), coverage (after tests)

License

This software is distributed under the Apache License Version 2.0

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

djangohitcounter-0.1.4.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file djangohitcounter-0.1.4.tar.gz.

File metadata

File hashes

Hashes for djangohitcounter-0.1.4.tar.gz
Algorithm Hash digest
SHA256 fb09c62dc03e6ff8e092f0c585fba1eb1e17edb3f43a11ed9b06e8a2fd0f4cd9
MD5 98075ad6950254bff0db778c450ea531
BLAKE2b-256 a45a1bcc9250444b998129dc31212a698f712d3e3593040b3f0c2ded628b0deb

See more details on using hashes here.

Supported by

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