2016-04-11 145 views
0

我有一個Django的問題,他說我的網址在他們確實(或我是盲人)時並不匹配。我已經在這裏回答了同樣的問題,但這些解決方案並沒有解決。Django「找不到頁面404」

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. 

網站\ 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'), 
] 

回答

1

你有一個錯字你music.urls

'r^$'應該是r'^$'

+0

很好的接收,我沒有看到。 – user13653

+0

@Francesco LOL!謝謝,兄弟,對於真正的T.T謝謝! –