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') ]