This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Welcome

Django visits is to be used as a hit-counter application for Django-powered web apps.

You have two ways of how to use this app; first is to count requested urls (CounterMiddleware), the second is to count object visits (aka models)

Configuration

You settings file should contain the following settings

  • MIN_TIME_BETWEEN_VISITS: (number) the minimum allowed time between visits for the user to update counter
  • IGNORE_URLS: (list) urls to ignore e.g. static urls etc. NOTE : only ignores by not incrementing the hit-counter for the request whose META.PATH_INFO starts with any string in this list. The visit is still logged though. Same thing happnes for IGNORE_USER_AGENTS and BOTS_USER_AGENTS settings below.
  • IGNORE_USER_AGENTS: (list) this is used to define what user agents to ignore. Regexes are supported
  • BOTS_USER_AGENTS: (list) this is used to define whether user is real or bot is user by BotVisitorMiddleware. Regexes are supported
  • REQUEST_FIELDS_FOR_HASH: (list) used to generate unique identifier for visitor
  • URI_WITH_GET_PARAMS: (bool) use get params to identify diferents uris
  • VISITS_OBJECTS_AS_COUNTERS: (bool) enable or disable the behavior of visits objects as counters (on False, every diferent visits is counted in a diferent object)

BOTS_USER_AGENTS by default will have the following values

[
    "Teoma", "alexa", "froogle", "Gigabot", "inktomi", "looksmart", "URL_Spider_SQL", "Firefly",
    "NationalDirectory", "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot", "crawler",
    "www.galaxy.com", "Googlebot", "Googlebot/2.1", "Google", "Webmaster", "Scooter", "James Bond",
    "Slurp", "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz", "Baiduspider",
    "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot", "Mediapartners-Google", "Sogou web spider",
    "WebAlta Crawler", "MJ12bot", "Yandex/", "YaDirectBot", "StackRambler", "DotBot", "dotbot"
]

Usage

  • Add visits to INSTALLED_APPS
INSTALLED_APPS = (
    # ...
    "visits",
)
  • If you want to filter some type of user agents you can define IGNORE_USER_AGENTS in your settings.py
IGNORE_USER_AGENTS = ["Wget/", "curl/"]
  • If you want to filter bots from real users then in MIDDLEWARE_CLASSES set
MIDDLEWARE_CLASSES = (
    # ...
    "visits.middleware.BotVisitorMiddleware",
)
  • If you want to count visits automatically per url the you should add CounterMiddleware to MIDDLEWARE_CLASSES
MIDDLEWARE_CLASSES = (
    # ...
    "visits.middleware.CounterMiddleware",
)
  • If you want to count visits automatically per url with get params you should add URI_WITH_GET_PARAMS=True to your settings.py
  • If you want count url visit manually you can do it the way below
from visits.models import Visits

def some_object_view(request, pk):
    Visit.objects.add_uri_visit(request, request.META["PATH_INFO"], APP_LABEL)
    #...
    #...
  • If you want count visits per object then it’s similar to the example above
from visits.models import Visits

def some_object_view(request, pk):
    some_obj = get_object_or_404(SOME_MODEL, pk=pk)
    Visit.objects.add_object_visit(request, obj=some_obj)
    #...
    #...
  • From inside of a template you can get
  • object visits using get_visits
  • url visits using get_visits templatetag
{% load visits_tags %}

{% get_visits some_model_instance as visits %}
{% get_visits some_request_instance as visits %}
{% get_visits some_uri_regex as visits %}

Note: to get uri visits using get_visits templatetag you should add the following to TEMPLATE_CONTEXT_PROCESSORS

TEMPLATE_CONTEXT_PROCESSORS = (
    #...
    "visits.context_processors.request_meta",
)

Have fun!

Release History

Release History

0.1.6

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-visits-0.1.6.tar.gz (7.3 kB) Copy SHA256 Checksum SHA256 Source Jun 16, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting