Search code examples
pythondjangonameerror

Python NameError: name 'include' is not defined


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?


Solution

  • 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