Unable to get django-debug-toolbar toolbar

No matter what I do, I just can't get django-debug-toolbar to appear. I tried everything that was offered in each answer to this question .

  • I have DEBUG=True in my settings
  • I have django.contrib.staticfiles and debug_toolbar in INSTALLED_APPS
  • I have 'debug_toolbar.middleware.DebugToolbarMiddleware' high in MIDDLEWARE_CLASSES
  • I have INTERNAL_IPS = () in my settings
  • I tried adding print("IP Address for debug-toolbar: " + request.META['REMOTE_ADDR']) to the view and typing IP Address for debug-toolbar: 127.0.0.1
  • I have a closure </body></html> in my template
  • I executed pip install django-debug-toolbar in my virtualenv without any problems.
  • I ran python manage.py collectstatic and there is a debug_toolbar directory in my static files

When I launch the application, I do not see the console request for any URLs containing django_debug_toolbar, so I suspect the application is not loading.

I also do not see failed requests in the developer console.

I read the django-debug-toolbar docs and don't know.

Does anyone have any suggestions for debugging? I am running OSX and Django 1.7. Curiously, the WAS debugging panel looks just great - I think I made some settings that made it disappear, but I don't know what.

UPDATE: I even tried adding this to my settings file, which should make the toolbar appear:

 def show_toolbar(request): return True SHOW_TOOLBAR_CALLBACK = show_toolbar 

But that does not help.

I also tried to make a deliberate exception in my view to verify that DEBUG is turned on and all the settings are listed above. They are and still do not have a toolbar!

UPDATE 2: When I set INTERNAL_IPS=('127.0.0.1',) , I start to see debug panel requests in the console, but there is no toolbar on the page.

And the following HTML appears on my page: so there is a toolbar, but it is not visible because it set all display=none :

enter image description here

+6
source share
5 answers

All div with display: none; actually behave correctly. They will not change to display: block; until you actually click them on the toolbar itself.

The button used to switch the toolbar is a div with id="djDebugToolbarHandle" . As you can see on the console, this button has a top position of 2310px . This means that it is rendering , but it just goes down the page.

Try entering the following in the console to reset its position:

 document.getElementById('djDebugToolbarHandle').style.top="30px"; 
+3
source

I had the same problem but managed to fix it after dvl comment on this page . Here is a summary of the fix:

In settings.py

 if DEBUG: MIDDLEWARE += ( 'debug_toolbar.middleware.DebugToolbarMiddleware', ) INSTALLED_APPS += ( 'debug_toolbar', ) INTERNAL_IPS = ('127.0.0.1', ) DEBUG_TOOLBAR_CONFIG = { 'INTERCEPT_REDIRECTS': False, } 

In the urls.py project, add this url template at the end:

 from django.conf import settings if settings.DEBUG: import debug_toolbar urlpatterns += [ url(r'^__debug__/', include(debug_toolbar.urls)), ] 
+3
source

One of the reasons that the django-debug toolbar may appear but not display correctly (elements inserted in the "Download") is if the manage.py collectstatic command has not been run. Just thought I'd post it here if that helps someone.

+1
source

Some information for news users like me when a developer on a virtual or remote machine

Add this lign to the views.py file

 print("IP Address for debug-toolbar: " + request.META['REMOTE_ADDR']) 

When the call calls the call, you can see the client IP address in the shell

You must add this IP file settings.py INTERNAL_IPS = ('IP')

0
source

I had the same problem. Changing the finder module in my .py settings worked for me:

 STATICFILES_FINDERS = ( #'django.contrib.staticfiles.finders.FileSystemFinder', #THIS BREAKES debug_toolbar 'django.contrib.staticfiles.finders.AppDirectoriesFinder', #THIS WORKS ) 

Be sure to clear your browser cache after this change.

But after that, Django gave me error messages during collectstatic , due to this problem . I decided to create two configurations in my .py settings:

 class Production(Base): DEBUG = False STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', ) class Develop(Base): DEBUG = True STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) 

Hope this helps.

0
source

Source: https://habr.com/ru/post/983639/


All Articles