ngageoint / scale

Processing framework for containerized algorithms
http://ngageoint.github.io/scale/
Apache License 2.0
105 stars 45 forks source link

Basic setup for django-debug-toolbar #1855

Closed mheppner closed 4 years ago

mheppner commented 4 years ago

Affected app(s)

Description of change

This adds support for django-debug-toolbar. This provides a collapsible sidebar (panels)on the right side of any HTML encoded response. Primarily, this will expose the ability to see the exact SQL query and timing data directly on an API endpoint.

This is enabled in production, but will only be visible by setting INTERNAL_IP environment variable to your client's IP (ex, your laptop is set to 192.168.1.100). This has not been tested with the many layers of proxies in our various prod environments, but I think it should work. Alternatively, I usually have a separate requirements.dev.txt that only installs the package, then in settings.py:

try:
    import debug_toolbar
except ImportError:
    pass
else:
    INSTALLED_APPS += ['debug_toolbar']
    # ...remaining setup

This method fully ensures the package is not even installed in production environments. Open to suggestions here, but INTERNAL_IPS should be sufficient.