Skip to main content

A reusable app to track view hits.

Installation

To get the latest stable release from PyPi

$ pip install django-traces

To get the latest commit from GitHub

$ pip install -e git+git://github.com/bitmazk/django-traces.git#egg=traces

Add traces to your INSTALLED_APPS

INSTALLED_APPS = (
    ...,
    'traces',
)

Add the traces URLs to your urls.py

urlpatterns = patterns('',
    ...
    url(r'^traces/', include('traces.urls')),
)

Don’t forget to migrate your database

./manage.py migrate traces

Usage

If you want to track a certain view just add our middleware:

MIDDLEWARE_CLASSES = (
    ...
    'traces.middleware.TracesMiddleware',
)

…and add the view name/url name to the setting TRACED_VIEWS. If you have added a view like this:

url(r'^$', TemplateView.as_view(template_name='test.html'), name='test_view'),

…your setting should look like:

TRACED_VIEWS = ['test_view', ]

The app will now track all visits to this view.

Template tags

get_view_hits

To get the current amount of requests for this view:

{% load traces_tags %}
{% get_view_hits as hits %}
Hits: {{ hits }}

You can also provide the view name to get any view hits:

{% load traces_tags %}
{% get_view_hits 'view_name' as hits %}
Hits: {{ hits }}

{% get_view_hits 'model_view_name' object as model_view_hits %}
Hits: {{ model_view_hits }}

Settings

TRACED_VIEWS

Default: []

List all view names to track.

Contribute

If you want to contribute to this project, please perform the following steps

# Fork this repository
# Clone your fork
$ mkvirtualenv -p python2.7 django-traces
$ python setup.py install
$ pip install -r dev_requirements.txt

$ git co -b feature_branch master
# Implement your feature and tests
$ git add . && git commit
$ git push -u origin feature_branch
# Send us a pull request for your feature branch

Release files for django-traces 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-traces 0.4
File Size Uploaded
django-traces-0.4.tar.gz 10.9 kB Details

Release files / django-traces-0.4.tar.gz

Download URL django-traces-0.4.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
41bd384e8d9a4748f5dc2eae56cb684b7eef9be593731910d7b555362857455b
BLAKE2b-256 checksum
How to use checksums
4fa7f85f7f2dce038df95197d0a7d9e6647e94cc0cdf7dffbb818fae28317282
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4 This release

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page