Django-debug-toolbar Doesn't work with jQuery on Django website

I am using django-debug-toolbar(latest version, v1.2.1) and I keep getting this error in the console:

Empty string passed to getElementById()

For this piece of code in jQuery (line 2757):

...
// HANDLE: $(#id)
} else {
elem = document.getElementById( match[2] );
...

Each link on the debug toolbar that I click causes a different warning to appear.

When I comment on my main jQuery source file, the debug toolbar works. Also, it works fine in the Django admin, apparently because the Django admin uses a different jQuery fetch method.

I tried @Carlton Gibson's answer, but this does not solve my problem. I also tried local jQuery from both CDN and several different versions to no avail ...

jQuery , django-debug-toolbar. , , .

, , , , . . , RequireJS django-debug-toolbar:

GET http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js [HTTP/1.1 304 Not Modified 133ms]
ReferenceError: jQuery is not defined localhost:8000:119
TypeError: djdt is undefined toolbar.js:297
Empty string passed to getElementById()

, jQuery , django-debug-toolbar ( DEBUG_TOOLBAR_CONFIG = { 'JQUERY_URL': '', }), , DjDT . - TypeError.

base.html, JS. , , .

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" defer></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js" defer></script>

, , . , , , , . , id, script class, . , DjDT .

. , id, , a. class, . , , . !

+4
2

, , , cue , settings.py ,

def show_toolbar(request):
    return True
SHOW_TOOLBAR_CALLBACK = show_toolbar

, , ; .

comment, jquery </body>, , ; . , jQuery script , async defer.

1: ,

- Firefox chrome ..? . , , "#" - , ( ), FireFox.

, html id, django-debug toolbar, #.

+1

jQuery , , . :

DEBUG_TOOLBAR_CONFIG = {
  'JQUERY_URL':'',
}

( . config docs).

, , .

+5

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


All Articles