ImportError : cannot import name include

944 views
Skip to first unread message

Tristan Demot

unread,
May 17, 2018, 2:57:14 PM5/17/18
to Django users
Hello,

 Python 2 7 13
Gjango 1.11.13

Creating the Polls app OK

Write your first view OK

But python manage runserver don't work
With : python -Wall manage.py test

ImportError : cannot import name include

If you want to see something, ask me

Many thanks


Fidel Leon

unread,
May 17, 2018, 3:02:08 PM5/17/18
to django...@googlegroups.com
You are using the wrong combination of Django and tutorial: “include” is available in Django 2 and up, but you’re using Django 1.11.

Fidel Leon
GPG: 2585 30C2 E3C7 7151 0864  946B 7423 F94B 5753 5FC7
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1fe7df04-dc85-4a3d-940e-4dde7de31477%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Hepper

unread,
May 17, 2018, 3:02:59 PM5/17/18
to django...@googlegroups.com
You are using Django 1.11 with the tutorial written for Django 2.0. Therr should be a version picker on the bottom right of the tutorial.

You are seeing this error because the way to import ‚include’ has changed from 1.11 to 2.0

Hope that helps,
Daniel

Pranay reddy

unread,
May 18, 2018, 2:32:54 AM5/18/18
to Tristan Demot
From which package you have imported "include "

Sent from my BlackBerry 10 smartphone.
From: Tristan Demot
Sent: Friday 18 May 2018 00:27
To: Django users
Subject: ImportError : cannot import name include

Journal-Immo

unread,
May 18, 2018, 10:21:30 AM5/18/18
to django...@googlegroups.com, Fidel Leon

Thank

But (I use debian 9)

Apt-get update

Apt-get install python python3 python-django

django-admin --version 1.11.13

Where is the problem ?


For more options, visit https://groups.google.com/d/optout.

--

Daniel Hepper

unread,
May 18, 2018, 10:39:50 AM5/18/18
to django...@googlegroups.com

Your problem is right here:

> django-admin --version 1.11.13

You are using Django 1.11. The documentation you are using refers to a newer version of Django, version 2.0.

Use the right documentation for your version of Django:


You are seeing this specific error because in Django 2.0, you can write "from django.urls import include", while in Django 1.11, you have to write "from django.conf.urls import include".

Note that using Debian packages, you won't get the latest version of Django (or any other Python packages). You might want to consider installing the latest version with pip.


Hope that helps,
Daniel

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

--

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Fidel Leon

unread,
May 18, 2018, 11:01:21 AM5/18/18
to django...@googlegroups.com
You need to follow the CORRECT tutorial:


In the urls.py file, instead of:

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

urlpatterns = [
    path('polls/', include('polls.urls')),
    path('admin/', admin.site.urls),
]
you need this:

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]
Please note the django.conf.urls INSTEAD of django.contrib
--

Gerald Brown

unread,
May 18, 2018, 11:07:12 AM5/18/18
to django...@googlegroups.com

Another option to get the current version of Django is to create a file called requirements.txt.  In this file enter django on a line, and other requirements on other lines.  You can also specify a specific version with django==1.11 or any other version by changing the number after the ==. If this is left off then the latest version will be installed.  Then in your virtual environment enter the command 'pip install -r requirements.txt'.  This will download and install everything that is in the requirements.txt.  This file will grow as you enter more requirements.

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Journal-Immo

unread,
May 18, 2018, 12:01:29 PM5/18/18
to django...@googlegroups.com, Daniel Hepper

Thank you for all your answers

I know my problem with version

So for me it's very strange...

python3 -V

Python 3.5.3

pip install Django==2.0.5

Collecting Django==2.0.5...

Could nt find a version... 1.2.1, 1.2.2 etc and the last one 1.11.13

No matching distribution found fot Django==2.0.5

Do you think Virtual Envirenment will solve my problem ?

Many thank again

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.

--

James Farris

unread,
May 18, 2018, 12:47:05 PM5/18/18
to django...@googlegroups.com, Daniel Hepper
If you are not using a virtual env, did you install pip3? If so, since you are using puthon3 -V to get that python version, try running 
$ pip3 install django 
And see if you get a different result

I think what is happening is when you run pip install it’s referencing another python version, not python 3. 

At least that is what I experienced back before I used virtual envs 

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

--
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHEnUVWWkRsOVD6AfvDoGS05z33R7qu9SuA2Q1o2se%2BPf0M-xg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages