Solved: ImportError: cannot import name ‘include’ / ‘path’ in Django tutorial

Did you encounter the error message:

ImportError: cannot import name 'include'


ImportError: cannot import name 'path'

when following the official Django tutorial or some other tutorial written for Django 2.0?

The most likely reason for that is that you are using an older version of Django. You are seeing this error because the tutorial uses features that were Django 2.0.

Double check that you are using the version of Django your tutorial was written for by running this command:

$ python -m django --version

If you are using a virtualenv, make sure it is activated before running any commands.

My suggestion would be to use the latest and greatest version of Django. However, if you want (or have) to use an older version of Django, make sure to use a tutorial that was written for this specific version to avoid any confusing errors. The official Django tutorial has a convenient version switcher on the bottom right of each page, as you can see in the image above.

If you are working on a legacy project using an old, unsupported version of Django, your version might no longer be listed on djangoproject.com. You can find documentation for older versions of Django here: https://readthedocs.org/projects/django/

Note that only the feature release version number matters, i.e. the first two parts of the version number. In version 2.0.1, the feature release version number is 2.0. The last part (1) is the patch release version, which is 100% compatible with the previous patch release. I highly would recommend to always use the latest patch release, i.e. at the time of this writing Django 2.0.2 with a tutorial written for Django 2.0 or Django 1.11.10 for a tutorial written for Django 1.11.

Leave a Reply