简体   繁体   English

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

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

When I am trying to run 当我试图跑步时

python manage.py makemigrations

The following error is shown, 显示以下错误,

    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.

Here is my project urls.py file, 这是我的项目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),
]

Quoting from the Django Documentation these are the possible signatures of include() method 引自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)) 


So change your urls.py as 因此,将您的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.

相关问题 不支持在 include() 中指定命名空间而不提供 app_name - Specifying a namespace in include() without providing an app_name is not supported 在 include() 中指定命名空间而不提供 app_name。 给 app_name 也不起作用 - Specifying a namespace in include() without providing an app_name. Giving app_name also doesn't work Django 2名称空间和app_name - Django 2 namespace and app_name 如何在 Django 中包含带有 app_name 的 url,而不必使用带有应用名称的反向? - How to include urls with app_name without having to use reverse with app name in Django? 在没有app_name的情况下url.py中的include关键字不起作用(Django 2.0) - Include keyword in url.py not working without app_name(Django 2.0) 如何在不提供 app_name 的情况下测试 django 应用程序 - How to test django app without giving an app_name 没有名为“social_django”的模块,但安装了“social-auth-app-django” - No module named 'social_django' but 'social-auth-app-django' is installed ImportError:没有名为“ social_django”的模块 - ImportError: No module named 'social_django' 使用Django时出现SyntaxError app_name - SyntaxError app_name while using Django 为什么 django-postman 不能用这个 -> url(r'^messages/', include('postman.urls', namespace='postman', app_name='postman')), - Why with django-postman that's doesn't work with this -> url(r'^messages/', include('postman.urls', namespace='postman', app_name='postman')),
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM