I'm having a program when I'm trying to run my server it's a pretty simple server because I'm quite new with Django

Viewed 67

This is the error I get:

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.

I tried removing the include() function, but I still get the error, what should I do?

Here is the code:

This is the main urls.py:

from django.conf.urls import include, url

from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'', include('learning_logs.urls', namespace='learning_logs')),

This is the secondary urls.py:

from django.conf.urls import url

from . import views

urlpatterns = [
    # Home page
    url(r'^$', views.index, name='index'),
]
1 Answers

You can not left empty the path. Try this:

url(r'^/', include('learning_logs.urls', namespace='learning_logs')),

Anyway, if you are using a django v2 or higher. I recommend you to use re_path and path methods. https://docs.djangoproject.com/en/3.1/topics/http/urls/ The new methods are more explicit and less error prone.

Related