1. 程式人生 > >解決:Specifying a namespace in include() without providing an app_name和XXX is not a registered namespace問題

解決:Specifying a namespace in include() without providing an app_name和XXX is not a registered namespace問題

info clu .py 添加 圖片 alt support 遇到 without

python3 Django 環境下,如果你遇到namespace沒有註冊以及在根目錄下urls.py中的include方法的第二個參數namespace添加之後就出錯的問題。

出錯問題:

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

解決方法:

請在[app_name]目錄下的urls.py中的urlpatterns前面加上app_name=‘[app_name]‘, [app_name]代表你的應用的名稱。可以參考這篇:https://stackoverflow.com/questions/14892462/django-error-upolls-is-not-a-registered-namespace

技術分享圖片

技術分享圖片

解決:Specifying a namespace in include() without providing an app_name和XXX is not a registered namespace問題