我不明白为什么我一直收到ModuleNotFoundError:没有名为' homepage‘的模块错误我对Django相当陌生,但是我花了一天的大部分时间来弄清楚如何制作一个主页,在那里我可以链接一个Homepage.html,并且在我的原始页面上有一个不同的页面。任何帮助都将不胜感激,这是我在这里的第二个问题,请温文尔雅。
这是在我的mysite/urls.py中
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('music.urls')),
url(r'^blog/', include('blog.urls')),
url(r'^HomePage/',include('HomePage.urls')),
]这是我在settings.py中安装的应用程序,位于mysite目录中。#应用定义
INSTALLED_APPS = [
'music',
'blog',
'homepage',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]这是我的music/urls.py urls.py
from django.conf.urls import url, include
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^contact/$', views.contact, name='contact'),
url(r'^HomePage/$', views.HomePage, name='HomePage'),
]这是views.py music/views.py
from django.shortcuts import render
def index(request):
return render(request, 'music/home.html')
def contact(request):
return render(request, 'music/basic.html', {'content':['If you would like to contact me, please email me','@gmail.com']})
def HomePage(request):
return render(request, 'HomePage/homepage.html')这是我的文件夹结构。
|-.git
| |-hooks
| |-info
| |-logs
| | |-refs
| | | |-heads
| | | |-remotes
| | | | |-origin
| |-objects
| | |-66
| | |-a9
| | |-aa
| | |-e2
| | |-e5
| | |-info
| | |-pack
| |-refs
| | |-heads
| | |-remotes
| | | |-origin
| | |-tags
|-.idea
| |-libraries
|-__pycache__
|-db
|-DGLIB
| |-mysite
| | |-blog
| | | |-__pycache__
| | | |-migrations
| | | | |-__pycache__
| | | |-templates
| | | | |-blog
| | |-homepage
| | | |-__pycache__
| | | |-migrations
| | |-music
| | | |-__pycache__
| | | |-migrations
| | | | |-__pycache__
| | | |-static
| | | | |-music
| | | | | |-css
| | | | | |-fonts
| | | | | |-img
| | | | | |-js
| | | |-templates
| | | | |-music
| | | | | |-img
| | | | | |-includes
| | |-mysite
| | | |-__pycache__
|-model
| |-__pycache__
|-notebooks
| |-.ipynb_checkpoints发布于 2018-04-04 12:00:02
更改此行:
url(r'^HomePage/',include('HomePage.urls')),至
url(r'^HomePage/',include('homepage.urls')),在你的urls.py文件中,因为你的INSTALLED_APPS中列出了'homepage‘,而不是'HomePage’。
https://stackoverflow.com/questions/49642388
复制相似问题