mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #903 from SchrodingersGat/debug-toolbar
Debug toolbar
This commit is contained in:
commit
411e7507a3
@ -91,6 +91,8 @@ class QueryCountMiddleware(object):
|
||||
To enable this middleware, set 'log_queries: True' in the local InvenTree config file.
|
||||
|
||||
Reference: https://www.dabapps.com/blog/logging-sql-queries-django-13/
|
||||
|
||||
Note: 2020-08-15 - This is no longer used, instead we now rely on the django-debug-toolbar addon
|
||||
"""
|
||||
|
||||
def __init__(self, get_response):
|
||||
|
@ -172,11 +172,15 @@ MIDDLEWARE = [
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'InvenTree.middleware.AuthRequiredMiddleware',
|
||||
|
||||
'InvenTree.middleware.AuthRequiredMiddleware'
|
||||
]
|
||||
|
||||
if CONFIG.get('log_queries', False):
|
||||
MIDDLEWARE.append('InvenTree.middleware.QueryCountMiddleware')
|
||||
# If the debug toolbar is enabled, add the modules
|
||||
if DEBUG and CONFIG.get('debug_toolbar', False):
|
||||
print("Running with DEBUG_TOOLBAR enabled")
|
||||
INSTALLED_APPS.append('debug_toolbar')
|
||||
MIDDLEWARE.append('debug_toolbar.middleware.DebugToolbarMiddleware')
|
||||
|
||||
ROOT_URLCONF = 'InvenTree.urls'
|
||||
|
||||
@ -377,3 +381,8 @@ DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage'
|
||||
DBBACKUP_STORAGE_OPTIONS = {
|
||||
'location': CONFIG.get('backup_dir', tempfile.gettempdir()),
|
||||
}
|
||||
|
||||
# Internal IP addresses allowed to see the debug toolbar
|
||||
INTERNAL_IPS = [
|
||||
'127.0.0.1',
|
||||
]
|
||||
|
@ -6,6 +6,7 @@ Passes URL lookup downstream to each app as required.
|
||||
|
||||
|
||||
from django.conf.urls import url, include
|
||||
from django.urls import path
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth import views as auth_views
|
||||
from qr_code import urls as qr_code_urls
|
||||
@ -135,5 +136,12 @@ urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
# Media file access
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
# Debug toolbar access (if in DEBUG mode)
|
||||
if settings.DEBUG and 'debug_toolbar' in settings.INSTALLED_APPS:
|
||||
import debug_toolbar
|
||||
urlpatterns = [
|
||||
path('__debug/', include(debug_toolbar.urls)),
|
||||
] + urlpatterns
|
||||
|
||||
# Send any unknown URLs to the parts page
|
||||
urlpatterns += [url(r'^.*$', RedirectView.as_view(url='/index/', permanent=False), name='index')]
|
||||
|
@ -58,9 +58,10 @@ static_root: '../inventree_static'
|
||||
# - git
|
||||
# - ssh
|
||||
|
||||
# Logging options
|
||||
# If debug mode is enabled, set log_queries to True to show aggregate database queries in the debug console
|
||||
log_queries: False
|
||||
# Set debug_toolbar to True to enable a debugging toolbar for InvenTree
|
||||
# Note: This will only be displayed if DEBUG mode is enabled,
|
||||
# and only if InvenTree is accessed from a local IP (127.0.0.1)
|
||||
debug_toolbar: False
|
||||
|
||||
# Backup options
|
||||
# Set the backup_dir parameter to store backup files in a specific location
|
||||
|
@ -21,4 +21,5 @@ python-coveralls==2.9.1 # Coveralls linking (for Travis)
|
||||
rapidfuzz==0.7.6 # Fuzzy string matching
|
||||
django-stdimage==5.1.1 # Advanced ImageField management
|
||||
django-tex==1.1.7 # LaTeX PDF export
|
||||
django-weasyprint==1.0.1 # HTML PDF export
|
||||
django-weasyprint==1.0.1 # HTML PDF export
|
||||
django-debug-toolbar==2.2 # Debug / profiling toolbar
|
Loading…
Reference in New Issue
Block a user