[英]Django “page not found 404”
我对Django有问题,他是说我的网址确实不匹配(否则我是盲目的)。 我已经尝试过在这里回答同样的问题,但是没有解决这些问题。
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/music/
Using the URLconf defined in website.urls, Django tried these URL patterns, in this order:
^admin/
^music/ r^$ [name='index']
The current URL, music/, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
website \\ 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')),
]
views.py:
from django.http import HttpResponse
def index(request):
return HttpResponse('<h1>This is the Music app homepage')
music.urls.py:
from django.conf.urls import url
from . import views
urlpatterns = [
url('r^$', views.index, name='index'),
]
您的music.urls
有错别字
'r^$'
应该是r'^$'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.