網站/ urls.py
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^music/', include('music.urls')),
]
音樂/ urls.py
from django.conf.urls import url
from . import index
urlpatterns = [
url('^$', views.index, name='index'),
]
views.py
from django.http import HttpResponse
def index(request):
return HttpResponse ("This is Music Homepage ")
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'music',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'website.urls'
問題
Using the URLconf defined in website.urls, Django tried these URL patterns, in this order:
^admin/
The current path, music, didn't match any of these.
錯誤仍不符合你的代碼。確保清除任何'.pyc'文件並重新啓動服務器。 – knbk