Lucas
Lucas

Reputation: 35

Specifying a namespace in include() without providing an app_name ' django.core.exceptions.ImproperlyConfigured

from django.urls import path
from django.conf.urls import include, url #22.JUN.2018 #25.Jun.2018
from django.contrib import admin

#from bookmark.views import BookmarkLV, BookmarkDV

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

I need you guys help!!! This is my code. And i have a error....please help me....

'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.

Upvotes: 2

Views: 2450

Answers (2)

Sonali Mahajan
Sonali Mahajan

Reputation: 94

You have to add a variable called app_name in the included urls.py module.

For example if you have this include in your project urls.py:

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

you have to add a variable:

app_name = 'bookmark'

just before the definition of urlpatterns variable in bookmark/urls.py file.

Upvotes: 5

Lucas
Lucas

Reputation: 35

I didn't know where you i write app_name=blog. However, i got it

Solution is going into the app file ex)/blog/urls.py and then write app_name='blog'

$ cd /home/꾸르잼/Django/mysite/bookmark
$ vi urls.py

from django.conf.urls import url
from bookmark.views import BookmarkLV, BookmarkDV

app_name='bookmark'

urlpatterns = [
# Class-based views
url(r'^$', BookmarkLV.as_view(), name='index'),
url(r'^(?P<pk>\d+)/$', BookmarkDV.as_view(), name='detail'),
]

If you have a same problem like me, hopefully you can solve it as watching this. Have a good day

Upvotes: 1

Related Questions