0

In my django rest framework app I have Urls.py as follows:

from django.urls import include, path
from .shipper import*
from .views import *


urlpatterns = [path('shipper/',
                    include(path('shipperitems/', MasterItemsList.as_view()),
                            path('shippercreateapi/', shipperCreateAPIView.as_view()),)),

               ]

When I try to run the app it gives me the following error:

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 t he list of patterns and app_name instead.

what should I do to resolve this ?

1

2 Answers 2

1

You are using the include(...) function in the wrong way. include(...) usually takes the module which contains url-patterns. So change your code as below,

#root urls.py
from django.urls import include, path

urlpatterns = [
    path('shipper/', include('shipper.urls')),
]

and

#/shipper/urls.py
urlpatterns = [
    path('shipperitems/', MasterItemsList.as_view()),
    path('shippercreateapi/', shipperCreateAPIView.as_view()),)),

]
Sign up to request clarification or add additional context in comments.

Comments

0

Check the docs for include here. You should pass paramters to include like this

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

(credits)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.