From 4a8a8b87d4a53649b655d449eed54ff1844c18e7 Mon Sep 17 00:00:00 2001 From: Goran Topic Date: Mon, 23 Oct 2017 14:37:54 +0900 Subject: [PATCH 1/2] Support for django debug toolbar --- gw2raidar/settings.py | 7 +++++++ raidar/urls.py | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gw2raidar/settings.py b/gw2raidar/settings.py index a0fdfcc8..e9481edd 100644 --- a/gw2raidar/settings.py +++ b/gw2raidar/settings.py @@ -37,6 +37,8 @@ # (it can be set in `settings_local.py`) ALLOWED_HOSTS = [] +INTERNAL_IPS = ['127.0.0.1'] + # Application definition @@ -160,3 +162,8 @@ from .settings_local import * except ImportError: pass + +if DEBUG: + if importlib.util.find_spec("debug_toolbar"): + INSTALLED_APPS.append('debug_toolbar') + MIDDLEWARE.append('debug_toolbar.middleware.DebugToolbarMiddleware') diff --git a/raidar/urls.py b/raidar/urls.py index 9926ae41..d1f21fd6 100644 --- a/raidar/urls.py +++ b/raidar/urls.py @@ -1,6 +1,7 @@ from django.conf import settings -from django.conf.urls import url +from django.conf.urls import url, include from django.contrib.auth import views as auth_views +import importlib from . import views @@ -30,3 +31,9 @@ url(r'^$', views.index, name = "index"), url(r'^global_stats(?:/(?P[0-9]+))?(?:/area-(?P[0-9]+))?(?P\.json)?$', views.global_stats, name = "global_stats"), ] + +if settings.DEBUG and importlib.util.find_spec('debug_toolbar'): + import debug_toolbar + urlpatterns = [ + url(r'^__debug__/', include(debug_toolbar.urls)), + ] + urlpatterns From aabb51adcdc0ae326a09ce50a7e2bd064044bf1e Mon Sep 17 00:00:00 2001 From: Goran Topic Date: Mon, 23 Oct 2017 06:29:08 +0000 Subject: [PATCH 2/2] Select related in encounter admin --- raidar/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/raidar/admin.py b/raidar/admin.py index 351416f9..72b8718f 100644 --- a/raidar/admin.py +++ b/raidar/admin.py @@ -81,6 +81,7 @@ def url_id_link(self, obj): search_fields = ('=url_id', '=filename', '^area__name', '=characters__name', '^characters__account__name', '=characters__account__user__username', '=tags__name', '=category__name') list_display = ('filename', 'url_id_link', 'area', 'success', 'category', 'started_at', 'duration', 'uploaded_at', 'uploaded_by') + list_select_related = ('category', 'uploaded_by', 'area') inlines = (ParticipationInline,) readonly_fields = ('url_id', 'started_at', 'duration', 'uploaded_at', 'uploaded_by', 'area', 'filename')