【问题标题】:Django "page not found 404"Django“找不到页面404”
【发布时间】:2016-08-01 23:32:01
【问题描述】:

我对 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.

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

【问题讨论】:

    标签: python django web frameworks


    【解决方案1】:

    您的music.urls 中有错字

    'r^$' 应该是r'^$'

    【讨论】:

    • 不错,我没看到。
    • @Francesco 哈哈!谢谢,兄弟...,真的 T.T 谢谢!
    猜你喜欢
    • 2016-08-01
    • 2015-10-22
    • 2014-03-20
    • 2020-10-27
    • 2019-07-21
    • 1970-01-01
    • 2016-03-31
    • 2017-02-09
    • 2021-10-17
    相关资源
    最近更新 更多