Thursday, July 19, 2018

Some errors encounter in Django 2.x Projects

ImportError: No module named 'django.core.urlresolvers'
Django 2.0 removes the django.core.urlresolvers module, which was moved to django.urls in version 1.10. You should change any import to use django.urls instead
from django.urls import reverse, NoReverseMatch

'WSGIRequest' object has no attribute 'user' Django admin
In Django 2.x  go to your setting and look for MIDDLEWARE_CLASSES. The new-style is MIDDLEWARE. Change it...

'djdt' is not a registered namespace
Not exactly Django 2.x problem, but because of django-debug-toolbar
Add debug_toolbar.middleware.DebugToolbarMiddleware in MIDDLEWARE, and add urlpattern:
if DEBUG:
 import debug_toolbar
 urlpatterns += [
  url(r'^__debug__/', include(debug_toolbar.urls)),
  ...
 ]

No comments:

Post a Comment