Django NameError: name 'include' is not defined in urls.py

30 views Asked by At
  1. I'm encountering a NameError in my Django project's urls.py file. When I try to use the include () function to include URLs from another app, I get the following error:

NameError: name 'include' is not defined

  1. Here's the relevant portion of my urls.py file:
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('admin/', admin.site.urls),
    path('hello/', include('hello.urls')) 
]

I've already imported include from django.urls, so I'm not sure why this error is occurring. Any insights on what might be causing this issue and how to resolve it would be greatly appreciated. Thank you!


  • I attempted to include URLs from another Django app in my project's urls.py file using the include() function.

  • I expected the include() function to work as intended and include the URLs from the specified app.

  • However, when I tried to use the include() function, I encountered a NameError stating that 'include' is not defined, even though I had imported it from django.urls.

0

There are 0 answers