Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/source/django-app.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ Setting details
Class must not have any constructor parameters and should implement __call__ method.


- Admin site support.
By default is False


.. code ::

USE_DJANGO_ADMIN_SITE = True




Manual Exception Tracking
~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
Binary file added docs/source/images/admin1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/admin2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ Features
.. image:: images/detail-page.png
:alt: Detailed Exception page

**Admin dashboard**

.. image:: images/admin1.png
:alt: Admin dashboard


.. image:: images/admin2.png
:alt: Admin dashboard



Quick start
Expand Down Expand Up @@ -141,6 +150,7 @@ We need to update settings.py file as
- Add Middleware :code:`error_tracker.django.middleware.ExceptionTrackerMiddleWare` for exception tracking [1]_.
- Other configs related to notification
- Add URLs to the list of URL patterns
- Enable django admin site (optional).

.. [1] This should be added at the end so that it can process exception 1st in the middleware call stack.

Expand Down Expand Up @@ -179,6 +189,12 @@ We need to add URLs to the urls.py so that we can browse the default pages provi
url("dev/", include(urls)),
]

To enable the error tracker in the admin site add this line in your settings.

.. code::

USE_DJANGO_ADMIN_SITE = True

Using With Python App (NO WEB SERVER)
-------------------------------------
Choose either of the preferred framework, flask or Django and configure the app as per their specifications.
Expand Down
34 changes: 34 additions & 0 deletions error_tracker/django/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from .models import ErrorModel
from django.contrib import admin
from .settings import USE_DJANGO_ADMIN_SITE

if USE_DJANGO_ADMIN_SITE:
@admin.register(ErrorModel)
class ErrorModelAdmin(admin.ModelAdmin):
date_hierarchy = 'last_seen'
list_display = (
'host',
'path',
'method',
'exception_name',
'count',
'created_on',
'last_seen',
'notification_sent',
'ticket_raised',
)
list_filter = (
'host',
'notification_sent',
'ticket_raised',
)
search_fields = ('host', 'path', 'exception_name',)
change_form_template = 'error_tracker/admin/change_form.html'

def changeform_view(self, request, object_id=None, form_url='', extra_context=None):
if object_id:
extra_context = {
'obj': ErrorModel.objects.get(pk=object_id)
}
return super().changeform_view(request, object_id=object_id,
form_url=form_url, extra_context=extra_context)
2 changes: 2 additions & 0 deletions error_tracker/django/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ def get(key, default):
APP_ERROR_NOTIFICATION_ONCE = get('APP_ERROR_NOTIFICATION_ONCE', False)
# Raise ticket once
APP_ERROR_TICKET_ONCE = get('APP_ERROR_NOTIFICATION_ONCE', False)
# Use django admin site
USE_DJANGO_ADMIN_SITE = get('USE_DJANGO_ADMIN_SITE', False)

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends 'admin/change_form.html' %}


{% block content %}
{% include 'error_tracker/detail.html' %}
{% endblock %}
1 change: 1 addition & 0 deletions examples/DjangoSample/DjangoSample/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@

STATIC_URL = '/static/'
APP_ERROR_DB_MODEL = "core.models.TestErrorModel"
USE_DJANGO_ADMIN_SITE = True
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def grep(attrname):
},
tests_require=[
"Flask-Mail",
'pyquery'
'pyquery',
"Django",
"djangorestframework",
"Flask",
Expand Down