簡體   English   中英

Django social_django'在include()中指定名稱空間而不提供app_name'

[英]Django social_django 'Specifying a namespace in include() without providing an app_name '

當我試圖跑步時

python manage.py makemigrations

顯示以下錯誤,

    path('account/', include('django.contrib.auth.urls', namespace='auth')),
File "/home/barsmansvps/DataScience/anaconda3/lib/python3.6/site-packages/django/urls/conf.py", line 39, in include
    '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.

這是我的項目urls.py文件,

from django.contrib import admin
from django.urls import path, include

# For google login
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('', include('home.urls')),
    # path('', include('pages.urls')),
    path('products/', include('products.urls')),
    path('reports/', include('reports.urls')),
    path('account/', include('social_django.urls', namespace='social')),
    path('account/', include('django.contrib.auth.urls', namespace='auth')),
    path('admin/', admin.site.urls),
]

引自Django文檔,這些是include()方法的可能簽名。

 include(module, namespace=None, app_name=None) include(pattern_list) include((pattern_list, app_namespace), namespace=None) include((pattern_list, app_namespace, instance_namespace)) 


因此,將您的urls.py更改為

urlpatterns = [
    path('', include('home.urls')),
    # path('', include('pages.urls')),
    path('products/', include('products.urls')),
    path('reports/', include('reports.urls')),

    path('account/', include(('social_django.urls', 'social_django'), namespace='social')), path('account/', include(('django.contrib.auth.urls', 'django'), namespace='auth')),

    path('admin/', admin.site.urls),
]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM