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’)),