我是初学者,我的网址有问题,
我有一个项目,在项目中我创建了一个名为" contacts"的应用程序,在应用程序中,我创建了一个文件夹" views",在这个文件夹中我有一个文件" index.py"
我的urls.py文件的内容如下:
#cat urls.py
"""pacha URL Configuration
The `urlpatterns` list routes URLs to views. For more information please
see:
https://docs.djangoproject.com/en/2.0/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'))
"""
from django.urls import *
from django.contrib import *
urlpatterns = [
re_path(r'^admin/', admin.site.urls),
re_path(r'^index$', include('contacts.urls')),
re_path(r'^$', contacts.views.index.page),
]
当我运行./manage.py runserver 0.0.0.0:8080
时
我收到这个错误:
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ImportError: No module named 'contacts.views.index.page';
'contacts.views.index' is not a package
谢谢!