Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django ORM Same Old ORM django-debug-toolbar

Debug Toolbar: 'djdt' is not a registered namespace

Hi,

I'm running the python files on a local server. But when I try to run manage.py, I get the following errors. How do I fix?

I tried this

https://github.com/bernardopires/django-tenant-schemas/issues/222

from . import settings

if settings.DEBUG:
    import debug_toolbar

    urlpatterns += patterns(
        '',
        url(r'^__debug__/', include(debug_toolbar.urls)),
    )

TRACEBACK AFTER ADDING settings.DEBUG

NameError at /
name 'patterns' is not defined
Request Method: GET
Request URL:    http://127.0.0.1:8000/
Django Version: 1.8.13
Exception Type: NameError
Exception Value:    
name 'patterns' is not defined
Exception Location: C:\Users\AJ\Google Drive\Django\django_debugtoolbar\learning_site\urls.py in <module>, line 35
Python Executable:  C:\Anaconda3\python.exe
Python Version: 3.5.2
Python Path:    
['C:\\Users\\AJ\\Google Drive\\Django\\django_debugtoolbar',
 'C:\\Anaconda3\\python35.zip',
 'C:\\Anaconda3\\DLLs',
 'C:\\Anaconda3\\lib',
 'C:\\Anaconda3',
 'c:\\anaconda3\\lib\\site-packages\\setuptools-23.0.0-py3.5.egg',
 'C:\\Anaconda3\\lib\\site-packages',
 'C:\\Anaconda3\\lib\\site-packages\\Sphinx-1.4.1-py3.5.egg',
 'C:\\Anaconda3\\lib\\site-packages\\win32',
 'C:\\Anaconda3\\lib\\site-packages\\win32\\lib',
 'C:\\Anaconda3\\lib\\site-packages\\Pythonwin']
Server time:    Mon, 27 Mar 2017 13:07:44 -0700

INITIAL TRACEBACK

Error during template rendering

In template C:\Anaconda3\lib\site-packages\debug_toolbar\templates\debug_toolbar\base.html, error at line 14
'djdt' is not a registered namespace
4   {% if toolbar.config.JQUERY_URL %}
5   <!-- Prevent our copy of jQuery from registering as an AMD module on sites that use RequireJS. -->
6   <script src="{% static 'debug_toolbar/js/jquery_pre.js' %}"></script>
7   <script src="{{ toolbar.config.JQUERY_URL }}"></script>
8   <script src="{% static 'debug_toolbar/js/jquery_post.js' %}"></script>
9   {% else %}
10  <script src="{% static 'debug_toolbar/js/jquery_existing.js' %}"></script>
11  {% endif %}
12  <script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
13  <div id="djDebug" class="djdt-hidden" dir="ltr"
14  
           data-store-id="{{ toolbar.store_id }}" data-render-panel-url="
      {% url 'djdt:render_panel' %}
      "


15       {{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }}>
16      <div class="djdt-hidden" id="djDebugToolbar">
17          <ul id="djDebugPanelList">
18              {% if toolbar.panels %}
19              <li><a id="djHideToolBarButton" href="#" title="{% trans "Hide toolbar" %}">{% trans "Hide" %} &#187;</a></li>
20              {% else %}
21              <li id="djDebugButton">DEBUG</li>
22              {% endif %}
23              {% for panel in toolbar.panels %}
24                  <li class="djDebugPanelButton">

2 Answers

Woow took me hours to get it running on mine, but try this out. am using Django version is 1.11.5 this is what i did at my settings.py

#KenethLove's setup
DEBUG_TOOLBAR_CONFIG = {
    'SHOW_TOOLBAR_CALLBACK': lambda x: True
}

DEBUG_TOOLBAR_PATCH_SETTINGS = False

finally at my url.py i used this code

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

i have tried this but it didn't worked for me check it out though. but the above settings should work. don't forget also, to set DEBUG = True

from django.conf import settings
from django.conf.urls import include, patterns, url

if settings.DEBUG:
    import debug_toolbar

    urlpatterns += patterns(
        '',
        url(r'^__debug__/', include(debug_toolbar.urls)),
    )

Thanks Gerard Nwazk for allowing the community to see this solution. I was having trouble getting the toolbar to show up as well. The first two code snippets were what solved my troubles. I am running django 1.11.7. It seems like the later 1.11 versions of django are interfering with the debug toolbar for some reason.