若报错

django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name att ribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.

主项目的urls.py

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/v1/shopper/', include(('shopper.urls', 'shopper'), namespace='shopper'))
]

∵ include的源码为:

urlconf_module, app_name = arg
arg里有两个参数

('shopper.urls', 'shopper')

 

模块的urls.py 

urlpatterns = [
    path('shopcart/', shopcartView.as_view(), name='shopcart'),
]

 

posted on 2023-12-05 20:29  koolman  阅读(15)  评论(0)    收藏  举报