Closed glennmatthews closed 4 years ago
This causes some breakage in my additional view unit tests that I'm working on locally; looking into it.
Okay, this appears to work. There seems to be some weirdness when running manage.py test
wherein DEBUG
is kind of "true but not really true", which caused any HTML view tests to fail due to loading but not really loading the debug toolbar. Adding an additional check to make sure we don't enable the debug toolbar when running manage.py test
seems to have fixed this issue.
Normally, when
DEBUG = True
in the Django settings, netbox presents thedjango-debug-toolbar
on requests whose source matchesINTERNAL_IPS
(by default, only 127.0.0.1 and ::1). When running in docker-compose, requests do not appear to be coming from localhost, but instead from the Docker bridge IP, which may vary.Since this is explicitly a development environment for the plugin, not a production deployment, the easiest way to work around this is to use django-debug-toolbar's own method of overriding the logic that checks INTERNAL_IPS, and simply have it present the toolbar on a request from any source so long as
DEBUG = True
.We have to provide this by patching netbox's
settings.py
, rather than in our standaloneconfiguration.py
, becausesettings.py
explicitly only imports specific variables fromconfiguration.py
and this is not one of them.