pythonpython-3.xdjangodjango-viewsdjango-urls

Unable to import path from django.urls


Tried to run command:

from django.urls import path

Getting error:

Traceback (most recent call last): File "< stdin >", line 1, in ImportError: cannot import name 'path'

I am using django version 1.11


Solution

  • The reason you cannot import path is because it is new in Django 2.0 as is mentioned here: https://docs.djangoproject.com/en/2.0/ref/urls/#path.

    On that page in the bottom right hand corner you can change the documentation version to the version that you have installed. If you do this you will see that there is no entry for path on the 1.11 docs.