(urls.E004). Your URL Pattern is invalid in project level urls.py file


I am newbie to Django. I am getting the below error in-spite of rightly mapping the app level urls.py file to project level urls.py. Please help.


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

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


from importlib.resources import path
from xml.etree.ElementInclude import include
from . import views

urlpatterns = [
path('app_space/', views.home_page)


?: (urls.E004) Your URL pattern <contextlib._GeneratorContextManager 
object at 0x0000024F8075D548> is invalid. Ensure that urlpatterns is 
a list of path() and/or re_path() instances.


put this in MainProjectFolder(where settings.py exists)/urls:

path('', include ('app_space.urls'))

and inside your app_space/urls.py you can but a custom url like app_space/

also make sure you import include and path

from django.urls import path, include

also add this line to settings.py/INSTALLED_APP -> ‘app_space’,

app_space -> your app name

Answered By – Hashem

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published