[Django]-Django 'ImportError: cannot import name url'

5👍

path was introduced in django since Django 2.0. So, if you are using Django 1.11, then you can’t use it. You need to define urls like this:

from django.conf.urls import url, include

urlpatterns = [
    # rest of the urls
    url(r'^$', HomeView.as_view()),

]
👤ruddra

1👍

correct your imports to this:

from django.urls import path, include

0👍

This code will work for you.

from django.urls import path
from django.contrib import admin

urlpatterns = [
    path('admin/', admin.site.urls),
]

Leave a comment