diff --git a/docs/source/django-app.rst b/docs/source/django-app.rst index 5665634..969302d 100644 --- a/docs/source/django-app.rst +++ b/docs/source/django-app.rst @@ -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 ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/source/images/admin1.png b/docs/source/images/admin1.png new file mode 100644 index 0000000..40e2fa7 Binary files /dev/null and b/docs/source/images/admin1.png differ diff --git a/docs/source/images/admin2.png b/docs/source/images/admin2.png new file mode 100644 index 0000000..59abc82 Binary files /dev/null and b/docs/source/images/admin2.png differ diff --git a/docs/source/index.rst b/docs/source/index.rst index 53c876b..ab2c1bc 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -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 @@ -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. @@ -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. diff --git a/error_tracker/django/admin.py b/error_tracker/django/admin.py new file mode 100644 index 0000000..683ddbf --- /dev/null +++ b/error_tracker/django/admin.py @@ -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) diff --git a/error_tracker/django/settings.py b/error_tracker/django/settings.py index e9b89e5..4e2e409 100644 --- a/error_tracker/django/settings.py +++ b/error_tracker/django/settings.py @@ -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) diff --git a/error_tracker/django/templates/error_tracker/admin/change_form.html b/error_tracker/django/templates/error_tracker/admin/change_form.html new file mode 100644 index 0000000..8c30af3 --- /dev/null +++ b/error_tracker/django/templates/error_tracker/admin/change_form.html @@ -0,0 +1,6 @@ +{% extends 'admin/change_form.html' %} + + +{% block content %} +{% include 'error_tracker/detail.html' %} +{% endblock %} \ No newline at end of file diff --git a/examples/DjangoSample/DjangoSample/settings.py b/examples/DjangoSample/DjangoSample/settings.py index e26f954..937ba22 100644 --- a/examples/DjangoSample/DjangoSample/settings.py +++ b/examples/DjangoSample/DjangoSample/settings.py @@ -116,3 +116,4 @@ STATIC_URL = '/static/' APP_ERROR_DB_MODEL = "core.models.TestErrorModel" +USE_DJANGO_ADMIN_SITE = True diff --git a/requirements.txt b/requirements.txt deleted file mode 100755 index ab058f3..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -six -Flask -Flask-SQLAlchemy -Django -djangorestframework \ No newline at end of file diff --git a/setup.py b/setup.py index 0347617..4b290ab 100755 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ def grep(attrname): }, tests_require=[ "Flask-Mail", - 'pyquery' + 'pyquery', "Django", "djangorestframework", "Flask",