前提・実現したいこと
Djangoチュートリアルを進めています。
チュートリアルに従って進めていったのですが、実行すると "Page not found" とエラーが出て来てしまいます。
いくつか同様の事例を調べてみたのですが、urls.pyの場所が間違っているわけではないと思うのですが・・・
原因が知りたいです。
発生している問題・エラーメッセージ
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/polls
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
admin/
The current path, polls, 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.
フォルダ構成
mysite
├── db.sqlite3
├── manage.py
├── mysite
│ ├── init.py
│ ├── pycache
│ ├── urls.py
│ ├── settings.py
│ └── wsgi.py
└── polls
├── init.py
├── admin.py
├── apps.py
├── migrations
├── models.py
├── tests.py
└── views.py
該当のソースコード
#mysite/polls/views.py from django.shortcuts import render from django.http import HttpResponse # Create your views here. def index(request): return HttpResponse("Hello")
#mysite/polls/urls.py from django.urls import path from . import views urlpatterns = [ path('',views.index,name='index'), ]
#mysite/mysite/urls.py from django.contrib import admin from django.urls import include, path urlpatterns = [ path('polls/', include('polls.urls')), path('admin/', admin.site.urls), ]
補足情報(FW/ツールのバージョンなど)
Python3.7.4
django2.2.4
回答1件
あなたの回答
tips
プレビュー