0
I’m having trouble with the include function, according to the Django documentation, the syntax is include(module, namespace=None)
,
include(pattern_list)
,include((pattern_list, app_namespace), namespace=None)
.
Source code
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = [
path('admin/', admin.site.urls),
path('clientes/', include("cliente.urls", namespace="cliente")),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Error
path('clientes/', include("cliente.urls", namespace="cliente")),
File "/home/phomint/DjangoProjects/Manager/myvenv/lib/python3.5/site-packages/django/urls/conf.py", line 39, in include
'Specifying a namespace in include() without providing an app_name '
django.core.exceptions.ImproperlyConfigured:
Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.
Did you look at the documentation for the right version? The information in the question differs from the documentation in 1.11: https://docs.djangoproject.com/en/1.11/ref/urls/#include
– Woss
I looked at my project and I’m using v2.1 and I looked at the documentation for it. @Andersoncarloswoss
– Patrick Amaral
You need to include app_name in the client app’s urls.py and not in the urls.py file you want to put include in. That’s why you keep giving the error.
– Felipe Messi