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?
The Python "NameError: name is not defined" occurs when we try to access a variable or function that is not defined or before it is defined. To solve the error, make sure you haven't misspelled the variable's name and access it after it has been declared.
NameError is raised when the identifier being accessed is not defined in the local or global scope.
NameError is a kind of error in python that occurs when executing a function, variable, library or string without quotes that have been typed in the code without any previous Declaration. When the interpreter, upon execution, cannot identify the global or a local name, it throws a NameError.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With