Python NameError: name 'include' is not defined

eloiletagant picture eloiletagant · Dec 26, 2015 · Viewed 83.1k times · Source

I'm currently developing a website with the framework Django (I'm very beginner), but I have a problem with Python: since I have created my templates, I can't run server anymore for this reason (the stack trace points to a line in file urls.py):

<stacktrace>
...
path('apppath/', include('myapp.urls')),
NameError: name 'include' is not defined

Where can I import include from?

Answer

Rahul Gupta picture Rahul Gupta · Dec 26, 2015

Guessing on the basis of whatever little information provided in the question, I think you might have forgotten to add the following import in your urls.py file.

from django.conf.urls import include