Installation
- Get the source
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.
hg clone http://dev.xairro.com/hg/django_statistics/
- Link it to your Python path
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.
ln -s /path/to/the/repository/django_statistics /usr/lib/python2.5/site-packages
- Add it to your INSTALLED_APPS
INSTALLED_APPS = ( # ... 'django_statistics', ) - Sync your database
python manage.py syncdb
- Add the middleware
I recommend adding it as your first middleware that it gets executed last.
MIDDLEWARE_CLASSES = ( 'django_statistics.middleware.StatisticMiddleware', # ... ) - Add a url to your urls.py file
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/
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), # ... ) - 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.
