Django-debug-toolbar: 'djdt' is not a registered namespace

Created on 28 Jan 2017  Â·  9Comments  Â·  Source: jazzband/django-debug-toolbar

Hi, its my 3 try of debugtoolbar and.. 3 times fail

First if couldnt get it shown.
2 years later same,
this time i get errors :

NoReverseMatch at /
'djdt' is not a registered namespace

I did everything in settings and URLS as i should

problem is in line 14:

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 }}>

django version 1.9 1.10, 1.10.04
debug panel 1.6 from PIP3

settings:

INSTALLED_APPS
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sites',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_hosts',
'ckeditor',
'django_user_agents',
'debug_toolbar',
'apps.core',
'apps.blog']

INTERNAL_IPS
('127.0.0.1', '192.168.1.41')

MIDDLEWARE_CLASSES
('django_hosts.middleware.HostsRequestMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django_hosts.middleware.HostsResponseMiddleware',
'django_user_agents.middleware.UserAgentMiddleware')

DEBUG is set to TRUE

Please.. help.. its frustrating i cannot use one of best tools for debuging for 3 years...

Most helpful comment

Thanks for your prompt response.

Actually, I got the same error but for a different reason. It was caused by
the debug-toolbar url route that I've pasted inside my app's url.py,
instead of putting it inside the project's url.py

On 25 Mar 2017 12:03 pm, "NomadDemon" notifications@github.com wrote:

Yes i figgured it out.
First i had some issues with configs, always prod config was used with
DEBUG = False. - fixed

Then was problem with no toolbar visible.
When using gunicorn with SOCK option instead of HTTP, no remote_addr is
passing. Had to manually used my own "validator for debugging user"

The 2nd part might be useful for other users.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/jazzband/django-debug-toolbar/issues/911#issuecomment-289207638,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AECBuNt3Zeul4JCyIhkb74hoRCbnCs80ks5rpQKggaJpZM4Lwdtd
.

All 9 comments

Most likely this error means you didn't configure the URLs correctly.

_CFG.DEBUG = True

if _CFG.DEBUG:
    import debug_toolbar
    urlpatterns += [
        url(r'^__debug__/', include(debug_toolbar.urls)),
        url(r'^site_media/(?P<path>.*)$',   serve, {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
        url(r'^static/(?P<path>.*)$',       serve, {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
    ]

Help.. please? :(

Looks good (I think). Maybe you could try showing us the whole URLconf file? Does /site_media/ work locally? What is _CFG? Is the code you posted part of your ROOT_URLCONF, or are you maybe already inside another namespace?

yes, it was part of root urls

from django.conf.urls.i18n import i18n_patterns
from django.conf.urls import url, include
from django.conf import settings
from django.contrib import admin
from django.views.decorators.cache import cache_page
from django.views.generic.base import RedirectView
from django.views.generic import *
from django.views.static import serve
from django.views.i18n import javascript_catalog
from django.utils.translation import ugettext_lazy as _

from ..core.views import *

import config as _CFG

admin.autodiscover()

urlpatterns = [
    url(r'^jsi18n/$', javascript_catalog),
    url(r'^jsi18n/(?P<packages>\S+?)/$', javascript_catalog),
    url(r'^i18n/', include('django.conf.urls.i18n')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^ckeditor/', include('ckeditor_uploader.urls')),
]

urlpatterns += [
    url(r'^lang/(?P<lang>[\w\-]+)$',    set_lang),
    url(r'^error-(?P<ID>\d+)$',  errors),

    url(r'^login/$',    login),
    url(r'^logout/$',   logout),

    url(r'^favicon\.ico$',  RedirectView.as_view(permanent=True, url='static/favicon.ico')),
    url(r'^favicon\.png$',  RedirectView.as_view(permanent=True, url='static/favicon.png')),
    url(r'^prev\.png$',     RedirectView.as_view(permanent=True, url='static/icons/prev.png')),
    url(r'^robots\.txt$',   RedirectView.as_view(permanent=True, url='static/robots.txt')),
    url(r'^sitemap\.xml$',  RedirectView.as_view(permanent=True, url='static/sitemap.xml')),
]

if _CFG.REGISTRABLE:
    urlpatterns += [
        url(r'^register/$', views.register),
        url(r'^activate', views.activate),
    ]

if _CFG.RESETABLE:
    urlpatterns += [
        url(r'^resetpass/$',    views.reset_password, {'typ' : 'resetpass'}),
        url(r'^resetpass2/$',   views.reset_password, {'typ' : 'resetpass2'}),
    ]

if _CFG.DEBUG:
    import debug_toolbar
    urlpatterns += [
        url(r'^__debug__/', include(debug_toolbar.urls)),
        url(r'^site_media/(?P<path>.*)$',   serve, {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
        url(r'^static/(?P<path>.*)$',       serve, {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
    ]

handler404 = my404
handler500 = my404

if len(_CFG.APP_LIST) == 0:
    exec(open('./apps/www/urls.py').read())

cfg is just additional config file i use in project. It contains only constant values

@NomadDemon Any progress with this issue?

Yes i figgured it out.
First i had some issues with configs, always prod config was used with DEBUG = False. - fixed

Then was problem with no toolbar visible.
When using gunicorn with SOCK option instead of HTTP, no remote_addr is passing. Had to manually used my own "validator for debugging user"

The 2nd part might be useful for other users.

Thanks for your prompt response.

Actually, I got the same error but for a different reason. It was caused by
the debug-toolbar url route that I've pasted inside my app's url.py,
instead of putting it inside the project's url.py

On 25 Mar 2017 12:03 pm, "NomadDemon" notifications@github.com wrote:

Yes i figgured it out.
First i had some issues with configs, always prod config was used with
DEBUG = False. - fixed

Then was problem with no toolbar visible.
When using gunicorn with SOCK option instead of HTTP, no remote_addr is
passing. Had to manually used my own "validator for debugging user"

The 2nd part might be useful for other users.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/jazzband/django-debug-toolbar/issues/911#issuecomment-289207638,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AECBuNt3Zeul4JCyIhkb74hoRCbnCs80ks5rpQKggaJpZM4Lwdtd
.

Thanks. I think this issue can be closed then. Good to hear debug toolbar works for both of you now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gosrinin picture gosrinin  Â·  8Comments

pstreck picture pstreck  Â·  6Comments

clarkbarz picture clarkbarz  Â·  8Comments

Arlington1985 picture Arlington1985  Â·  5Comments

mwoodward-atd picture mwoodward-atd  Â·  11Comments