Skip to main content

INSTALL

To run the demo project for testing:

$ git clone git://github.com/jojax/django-js-error-hook.git
$ cd django-js-error-hook
$ virtualenv env --python=python3
$ source env/bin/activate
(env) $ pip install -e .
(env) $ pip install -e demo
(env) $ demo migrate

Run the server:

(env) $ demo runserver

Then access: http://localhost:8000/ - the JavaScript error will be logged in your console.

To install the project in production:

$ pip install django-js-error-hook

Add django-js-error-hook to your INSTALLED_APPS settings:

INSTALLED_APPS = (
    ...
    'django.contrib.staticfiles',
    'django_js_error_hook',
    ...
)

If you want to log the error in the console for development:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '\033[22;32m%(levelname)s\033[0;0m %(message)s'
        },
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
            },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
        'javascript_error': {
            'handlers': ['mail_admins', 'console'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

By default the logger is called “javascript_error”, if you want you can define JAVASCRIPT_ERROR_ID in your settings:

JAVASCRIPT_ERROR_ID = '<your logger name>'

The view will do csrf validation - if for some reason it doesn’t work, set JAVASCRIPT_ERROR_CSRF_EXEMPT to True in your settings.

Then install the urls:

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

In your template, simply add the js_error_hook script:

<script type="text/javascript" src="{% url 'js-error-handler-js' %}"></script>

Now every JavaScript error will be logged in your logging error stream. (Mail, Sentry, …)

Have fun and feel free to fork us and give us feedbacks!

Release files for django-js-error-hook 0.8

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-js-error-hook 0.8
File Size Uploaded
django-js-error-hook-0.8.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-js-error-hook 0.8
File Interpreter ABI Platform
django_js_error_hook-0.8-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / django-js-error-hook-0.8.tar.gz

Download URL django-js-error-hook-0.8.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
edf0a8728897e47367ea7f81c7fbdf298d59d9344270e48f915917338be23027
BLAKE2b-256 checksum
How to use checksums
0a8add676650091875f281b0475ecdf476bd92299b816bcb2f971c4e68c2e0b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.19.7 CPython/3.6.9

Release files / django_js_error_hook-0.8-py3-none-any.whl

Download URL django_js_error_hook-0.8-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d56d7322a35ee189ff0f69ff030f27f476c3464b766cc2050d0cbae05781f554
BLAKE2b-256 checksum
How to use checksums
ba7b664498f5b07139fae0f55a248fb466b88fc3722909c11b318cf84cbaf9a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.19.7 CPython/3.6.9

Release history Release notifications | RSS feed

1.0

2 release files

This release

0.8 This release

2 release files

0.7

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

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