Django can' t load Module 'debug_toolbar': No module named 'debug_toolbar'
Question:
When I try running the project, Django can not load the django-debug-toolbar plugin for some reason. Error message says:
web_1 | ModuleNotFoundError: No module named 'debug_toolbar'
Here is my settings.py
INSTALLED_APPS = [
# ...
'django.contrib.staticfiles',
# ...
'debug_toolbar',
]
MIDDLEWARE = [
# ...
'debug_toolbar.middleware.DebugToolbarMiddleware',
# ...
]
INTERNAL_IPS = ('127.0.0.1', '192.168.0.1',)
Answers:
If you have not installed the django-debug-toolbar
package you can install it with help of the below command:
pip install django-debug-toolbar
I had to re-install django-debug-toolbar
by adding it to requirements.txt
and then running:
docker-compose build web
After doing that, the toolbar wasn’t still showing. I had to add this code to the settings.py file
def show_toolbar(request):
return True
DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK" : show_toolbar,
}
Answered here: https://stackoverflow.com/a/10518040/11011598
You can use the below command which worked perfectly for me:
$ python -m pip install -e git+https://github.com/jazzband/django-debug-toolbar.git#egg=django-debug-toolbar
I did run across the same problem when trying to use debug toolbar with Django & docker.
The solution posted above did not solve the problem entirely. The toolbar was sometimes not visible on the rest_framework
browsable API.
I solved the problem by adding the below into my settings.py
INTERNAL_IPS = ['127.0.0.1',"0.0.0.0:8000"]
import socket
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS += [".".join(ip.split(".")[:-1] + ["1"]) for ip in ips]
ref:
https://knasmueller.net/fix-djangos-debug-toolbar-not-showing-inside-docker
I ran across this issue because we’re using docker containers for the development environment and we’re also using Pipenv to manage deps. Silly me, I did:
pipenv install django-debug-toolbar --dev
When in my environment this does no good because it will never be installed on my docker container environment. I had to reinstall without the --dev
part and it worked fine afterwards.
Hope this helps someone out in the same situation.
When I try running the project, Django can not load the django-debug-toolbar plugin for some reason. Error message says:
web_1 | ModuleNotFoundError: No module named 'debug_toolbar'
Here is my settings.py
INSTALLED_APPS = [
# ...
'django.contrib.staticfiles',
# ...
'debug_toolbar',
]
MIDDLEWARE = [
# ...
'debug_toolbar.middleware.DebugToolbarMiddleware',
# ...
]
INTERNAL_IPS = ('127.0.0.1', '192.168.0.1',)
If you have not installed the django-debug-toolbar
package you can install it with help of the below command:
pip install django-debug-toolbar
I had to re-install django-debug-toolbar
by adding it to requirements.txt
and then running:
docker-compose build web
After doing that, the toolbar wasn’t still showing. I had to add this code to the settings.py file
def show_toolbar(request):
return True
DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK" : show_toolbar,
}
Answered here: https://stackoverflow.com/a/10518040/11011598
You can use the below command which worked perfectly for me:
$ python -m pip install -e git+https://github.com/jazzband/django-debug-toolbar.git#egg=django-debug-toolbar
I did run across the same problem when trying to use debug toolbar with Django & docker.
The solution posted above did not solve the problem entirely. The toolbar was sometimes not visible on the rest_framework
browsable API.
I solved the problem by adding the below into my settings.py
INTERNAL_IPS = ['127.0.0.1',"0.0.0.0:8000"]
import socket
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS += [".".join(ip.split(".")[:-1] + ["1"]) for ip in ips]
ref:
https://knasmueller.net/fix-djangos-debug-toolbar-not-showing-inside-docker
I ran across this issue because we’re using docker containers for the development environment and we’re also using Pipenv to manage deps. Silly me, I did:
pipenv install django-debug-toolbar --dev
When in my environment this does no good because it will never be installed on my docker container environment. I had to reinstall without the --dev
part and it worked fine afterwards.
Hope this helps someone out in the same situation.