ModuleNotFoundError:没有名为"操场/urls"的模块我正在经历莫什·哈梅达尼的终极django系列,我遇到了一个问题。我完全按照他的做法做了,但这对我不起作用。以下是我的urls.py和安装的应用程序。
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.staticfiles',
'playground'
]
游乐场/uls.py
from django.urls import path
from . import views
#URLConf
urlpatterns = [
path('hello/', views.say_hello)
]
店面/uls.py
"""storefront URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.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'))
"""
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('playground/', include('playground/urls'))
]
可能使用include('appname.ulls'(
更改
path('playground/', include('playground/urls'))
至
path('playground/', include('playground.urls'))
尝试:
path('playground/', include('playground.urls'))
Insteed of:
path('playground/', include('playground/urls'))
你可以在Django教程上查看该部分
希望对你有所帮助!
如果你发布终端给你的东西,这有时也很有帮助,据我所知,模型不存在,
尝试python管理.py makemigrations