arocks / edge

A Django project skeleton that is modern and cutting edge.
http://django-edge.readthedocs.org/
MIT License
840 stars 247 forks source link

django.urls.exceptions.NoReverseMatch: 'djdt' is not a registered namespace #67

Open elebumm opened 7 years ago

elebumm commented 7 years ago

I followed all the instructions to get this deployed and when I run the server and connect using Google Chrome I get this error here. I am unsure as to how to fix this.

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

elebumm commented 7 years ago

This has something to do with the DebugToolbarMiddleware I believe

elebumm commented 7 years ago

So I disabled DEBUG mode and changed ALLOWED_HOSTS now the website loads but I get no css?

acidjunk commented 7 years ago

Did you run manage.py collectstatic (seems you never did setup Django for production)

elebumm commented 7 years ago

I never ran that but after running it I got this error:

raise ImproperlyConfigured("You're using the staticfiles app " django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path

acidjunk commented 7 years ago

Deploying an Django app in production involves more then adding an item to ALLOWED_HOSTS and turning off debug. https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

Not only should you setup and folder that will contain the selected static files, you probably also have to configure part of your webserver for it. Same goes for MEDIA_FILES.

aunermedina commented 7 years ago

elebumm,

You need to add and modify the following info:

development.py file: Django Debug Toolbar (you need to modify to add the name of the app) INSTALLED_APPS += ( 'debug_toolbar',)

'debug_toolbar.apps.DebugToolbarConfig',)

Django Debug Toolbar Middleware (and you need to add the middleware classes. MIDDLEWARE_CLASSES += ( 'debug_toolbar.middleware.DebugToolbarMiddleware', )

finally in the urls.py file add the following:

if settings.DEBUG:
    import debug_toolbar

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

more info of this at http://django-debug-toolbar.readthedocs.io/en/stable/installation.html

I hope you found this helpful.

artforlife commented 7 years ago

I followed the documentation and also get the same error. More or less new to Django, so this is frustrating.

artforlife commented 7 years ago

There seems to be some kind of compatibility problem. I have tried this on 1.8-1.10 and they all break with different errors (missing or undefined includes).

emilgeorgejames1 commented 7 years ago

You have to explicitly setup debug_toolbar:

Add below line in your settings.py(in this case base.py):

DEBUG_TOOLBAR_PATCH_SETTINGS = False

Add the Debug Toolbar’s URLs to your project’s URLconf as follows:

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)),
    )

Then Enable Debug Toolbar in your MIDDLEWARE_CLASSES as follows:

(Add below line in your settings.py(in this case base.py) inside MIDDLEWARE_CLASSES you have to add )

'debug_toolbar.middleware.DebugToolbarMiddleware',

Save and runserver:

python manage.py runserver

more info of this at http://django-debug-toolbar.readthedocs.io/en/stable/installation.html

arocks commented 7 years ago

Hi all,

Sorry for these issues due to significant upstream changes in Django Toolbar. I was trying to figure out the most appropriate migration path. I also did not want to change any non-development code as Django toolbar should be limited to development only.

I have made my latest commit 3a17284f63b07ce91a0313ff69c3b966738c70d1 to the master to fix these issues. I recommend upgrading all pip packages and then rerunning the installation. Or you can learn the changes from the commit and apply them to your existing projects.

Would like to thank @elebumm, @acidjunk , @medincar , @artforlife and @emilgeorgejames1 for your helpful inputs. You are really the ones taking this project to the edge! 😄

Please comment here if you face any problems now. I shall close this issue in a few days.

Thanks! Arun

aswinkp commented 7 years ago

I faced the same issue today. I use ngrok to tunnel the local to internet . I get this error #67. No problem when I use in localhost. # I then added '.ngrok.com' to ALLOWED_HOSTS and everything works fine now.

arshpreetsingh commented 7 years ago

Hi, It is working fine in Production but not able to see CSS, even not after runnint 'python manage.py collectstatic'

arshpreetsingh commented 7 years ago

It worked fine now. This tutorial helped me to make application live on Production. https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04 may be I can write more details in the docs about deploying on Production

mizamae commented 7 years ago

Hello guys!

I am having exactly this same problem trying to make it work Django on a raspberry PI with Raspian. I have checked that all the file modifications listed here are applied but still happens...

Any help??

image

HT-Moh commented 6 years ago

Just make sure the following code inside the urls project file not the App url file

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

snake-soft commented 4 years ago

I had the same error. The toolbar worked but when running tests it threw

django.urls.exceptions.NoReverseMatch: 'djdt' is not a registered namespace

I am using a Custom User model subclassing Abstractuser and i splitted urls.py into one urls.py in every app directory.

Since I moved the Debug Toolbar url patterns from the main urls.py into the users.urls.py the error is gone.

convers39 commented 3 years ago

Tried and still have the same issue. If I turn off the debug to Fasle manually, then the error is gone, if I just run manage.py test with all those settings in the official doc, then I get the same error. django.urls.exceptions.NoReverseMatch: 'djdt' is not a registered namespace

cn-atlas commented 2 years ago

Just make sure the following code inside the urls project file not the App url file

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

i fix my problem with make sure

`if settings.DEBUG: import debug_toolbar

urlpatterns = [
                  path('__debug__/', include(debug_toolbar.urls)),
              ] + urlpatterns`

in project file not in app urlfile, THX