Когда я запускаю python Manage.py runserver , я получаю следующее сообщение
Код: Выделить всё
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
November 16, 2021 - 06:17:59
Django version 3.1.1, using settings 'lecture3.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Not Found: /
[16/Nov/2021 06:18:02] "GET / HTTP/1.1" 404 2029
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
November 16, 2021 - 06:25:43
Django version 3.1.1, using settings 'lecture3.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Not Found: /
[16/Nov/2021 06:25:46] "GET / HTTP/1.1" 404 2029
Код: Выделить всё
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/
Using the URLconf defined in lecture3.urls, Django tried these URL patterns, in this order:
admin/
hello/
The empty path didn't match any of these.
Код: Выделить всё
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name="index")
]
Код: Выделить всё
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def index(request):
return HttpResponse("Hello, world!")
Код: Выделить всё
from django.contrib import admin
from django.urls import path, include
from django.urls.conf import include
urlpatterns = [
path('admin/', admin.site.urls),
path('hello/', include("hello.urls"))
]
но
Код: Выделить всё
http://127.0.0.1:8000/admin works fine
http://127.0.0.1:8000/hello works fine
Когда я удаляю последнюю строку path('hello/', include("hello.urls")) из лекции3/lecture3/urls.py http://127.0.0.1:8000/ работает нормально
Подробнее здесь: https://stackoverflow.com/questions/699 ... 1-404-2029