점프 투 장고 2-01 URL과 뷰 부분에서 질문 드립니다.
안녕하세요, 점프 투 장고로 하나씩 해 보고 있는 왕초보입니다.
** 처음에 따라 하면서 로컬 서버 구동시키면, "성공적으로 설치되었습니다! 축하합니다" 페이지가 잘 나옵니다.
** 다음에 urls.py 파일을 아래와 같이 수정하고,
from django.contrib import admin
from django.urls import path
from pybo import views
urlpatterns = [
path('admin/', admin.site.urls),
path('pybo/', views.index),
]
** views.py 파일을 아래와 같이 수정한 다음,
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("안녕하세요, pybo에 오신 것을 환영합니다.")
** 브라우저에서 "http://localhost:8000/pybo" 요청하면, " "안녕하세요, pybo에 오신 것을 환영합니다."까지 나옵니다.
그런데... 처음에 잘 나왔던 "성공적으로 설치되었습니다! 축하합니다" 페이지는 아래와 같은 오류가 나옵니다.
(브라우저에 http://localhost:8000 만 입력)
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/
pybo/
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.
왜 그런 걸까요 ??? 그리고, 이걸 제대로 나오게 하기 위해서는 어떻게 해야 하는지요 ???
미리 감사의 말씀을 드립니다.
이른아침에 님 402
M 2022년 2월 8일 5:16 오후