raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) django.core.exceptions.ImproperlyConfigured:
The included URLconf '<module 'users.urls' from 'D:\\mygitfile\\meiduo_project\\meiduo_mall\\meiduo_mall\\apps\\users\\urls.py'>' does not appear to have any patterns in it.
If you see valid patterns in the file then the issue is probably caused by a circular import.
錯誤來源:配置子應用的url時,啟動django項目報錯
錯誤原因:啟動django項目,django框架會加載路由配置,如果在總路由添加了子應用,
那么需要在子應用文件下新建一個urls.py文件 並且要加上 urlpatterns=[]
例如:主應用 url.py
"""meiduo_mall 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.contrib import admin from django.urls import include, path urlpatterns = [ path('admin/', admin.site.urls), path('users/', include(('users.urls', 'users'), namespace='users')), ]
子應用urls.py
from django.urls import path from . import views urlpatterns=[ path('register/',views.RegisterView.as_view(),name='register') ]