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

Server throws 'NoReverseMatch: 'djdt is not a registered namespace' while launching learning_site:8000 w/ debug-toolbar

Here is the initial report from the Console session: System check identified no issues (0 silenced).
July 26, 2017 - 09:45:14
Django version 1.11.3, using settings 'learning_site.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Internal Server Error: /
Traceback (most recent call last):
File "/home/treehouse/.local/lib/python3.5/site-packages/django/urls/base.py", line 77, in reverse
extra, resolver = resolver.namespace_dict[ns]
KeyError: 'djdt'

I can't continue until this error is resolved. Help, please!

3 Answers

Gul Asnani
Gul Asnani
15,138 Points

Add this in your urls.py:

from django.conf import settings

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

Also don't forget to add this to your settings.py:

INTERNAL_IPS = ('127.0.0.1','::1', '0.0.0.0')

And in your tuple of MIDDLEWARE_CLASSES, this: 'debug_toolbar.middleware.DebugToolbarMiddleware'

Hope it helps:)

Natalie Tan
Natalie Tan
25,519 Points

Thanks, This works =)

Perry Adkins
Perry Adkins
8,413 Points

I am getting the same error message. I have tried changing the urls.py based on the recommendation of the django debug toolbar docs with no success. Thank you in advance for your assistance Seth Kroger.

Try placing the code from the answer above,

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

below, or after, your urlpatterns variable statement. That's the only way I was finally able to get this to work.