【发布时间】:2021-02-08 03:31:42
【问题描述】:
我正在学习 tom artyn 的这个教程。
我的代码与书中他的完全一样,但是,每次我尝试在 localhost 服务器上呈现我的网页时,我都会不断收到 Page not found (404) 错误。
这是我的项目(配置)网址:
from django.urls import path, include
from django.contrib import admin
import core.urls
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('core.urls', namespace = 'core')),
]
这是我的应用(核心)网址:
from django.urls import path
from . import views
app_name ='core'
urlpatterns = [
path('movies', views.MovieList.as_view(), name = 'MovieList'),
]
这是我的应用(核心)视图:
from django.views.generic import ListView
from core.models import Movie
# Create your views here.
class MovieList(ListView):
model = Movie
这是我的应用(核心)管理员:
from django.contrib import admin
# Register your models here.
from core.models import Movie
admin.site.register(Movie)
我不知道为什么请求与 '' url 不匹配。
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/
Using the URLconf defined in config.urls, Django tried these URL patterns, in this order:
admin/
movies [name='MovieList']
The empty path 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.
【问题讨论】: