Reputation:
I am getting this error:
ERRORS:
app_1 | ?: (urls.E004) Your URL pattern [<URLPattern '^static/media/(?P<path>.*)$'>] is invalid. Ensure that urlpatterns is a list of path() and/or re_path() instances.
app_1 | ?: (urls.E004) Your URL pattern [<URLPattern '^static/static/(?P<path>.*)$'>] is invalid. Ensure that urlpatterns is a list of path() and/or re_path() instances.
I don't know why I am getting this error. I have correctly added everything in my url patterns
urlpatterns = [
path("admin/", admin.site.urls),
path("api/v1/jobs/", include("jobs.urls")),
path("api/v1/company/", include("company.urls")),
]
if settings.DEBUG:
urlpatterns.extend(
[
static("/static/static/", document_root="/vol/web/static"),
static("/static/media/", document_root="/vol/web/media"),
path("__debug__/", include(debug_toolbar.urls)),
]
)
Upvotes: 1
Views: 2357
Reputation: 1
I only cleared all my cache and now running perfect my project at 8000 port.
Upvotes: -1
Reputation: 16515
The function static()
returns a list already, not a single pattern. It could be that the list contains a single path element, but it is a list nonetheless.
I suggest you change your code to:
if settings.DEBUG:
# add multiple paths using 'extend()'
urlpatterns.extend(static("/static/static/", document_root="/vol/web/static"))
urlpatterns.extend(static("/static/media/", document_root="/vol/web/media"))
# add a single path using 'append()'
urlpatterns.append(path("__debug__/", include(debug_toolbar.urls)))
Upvotes: 2