Unable to import path from django.urls

Lev picture Lev · Nov 29, 2017 · Viewed 109.1k times · Source

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

Answer

Nick Chapman picture Nick Chapman · Nov 29, 2017

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.