TypeError: view must be a callable or a list/tuple in the case of include()

1、TypeError: view must be a callable or a list/tuple in the case of include()

Django version 3.1.3
如下为官方样例:

“”"paper_notes URL Configuration

The urlpatterns list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path(’’, views.home, name=‘home’)
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path(’’, Home.as_view(), name=‘home’)
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path(‘blog/’, include(‘blog.urls’))
“”"

但是path不支持正则匹配,想用正则得用url
url(r’^$’, views.index, name=‘index’)

2、
TypeError: _path() got an unexpected keyword argument ‘namespace’

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

原来path(r’’, include(‘paper_notes2.urls’, namespace=‘paper_notes2’)),
解决path(r’’, include((‘paper_notes2.urls’,“paper_notes2”),namespace=‘paper_notes2’)),

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Andy_2259

如有用,请点赞哦~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值