Installation

  1. Get the source
    hg clone http://dev.xairro.com/hg/django_statistics/
    
    If you don't want to install Mercurial, you can download the repository as an archive. Just follow this link and click on a [zip] [gz] or [bz2] button.
  2. Link it to your Python path
    ln -s /path/to/the/repository/django_statistics /usr/lib/python2.5/site-packages
    
    Remember to adjust the paths. You must be root to link it to the global site-packages directory. Important: The repository is called django_statistics but there is a directory in it with the same name. So for example the symlink must point to /foo/bar/django_statistics/django_statistics/ if /foo/bar/django_statistics/ is the repository.
  3. Add it to your INSTALLED_APPS
    INSTALLED_APPS = (
        # ...
        'django_statistics',
    )
    
  4. Sync your database
    python manage.py syncdb
    
  5. Add the middleware
    MIDDLEWARE_CLASSES = (
        'django_statistics.middleware.StatisticMiddleware',
        # ...
    )
    
    I recommend adding it as your first middleware that it gets executed last.
  6. Add a url to your urls.py file
    urlpatterns = patterns('',
        # ...
        url(r'^admin/stats/', include('django_statistics.urls')),
        url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
        url(r'^admin/(.*)', admin.site.root),
        # ...
    )
    
    This is just an example but you need to add ist before the ^admin/(.*) urlpattern if you want to use a URL that starts with admin/
  7. You should add an URL alias to the configuration file of your webserver. This may look like this (lighttpd config):
    alias.url = (
        "/admin/stats/m" => "/usr/lib/python2.5/site-packages/django_statistics/media/",
    )
    url.rewrite-once = (
        "^(/admin/stats/m/.*)$" => "$1",
    )
    
    If you don't add this line, Django will serve the static files. That'll be a lot slower.

Known Issues

Known Issues