0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Django】Build web apps ~2章:ViewsとURL Patterns~

Last updated at Posted at 2020-02-18

Django web app作成

【Django】Build web apps ~1章:プロジェクト作成~

views.py

view.py
from django.http import HttpResponse
def index(request):
    return HttpResponse('HELLO WORD')

urls.py作成

food appへディレクトリし、urls.pyファイルを作成し

urls.py(food)
from . import views
from django.urls import path
urlpatterns = [
    path('', views.index, name='index'),
]
urls.py(mysite)
from django.urls import include
urlpatterns = [
    path('admin/', admin.site.urls),
    path('food/', include('food.urls')),
]

動きの説明

image.png
👇
ROOT_URLCONF
👇
settings.py
👇
image.png
👇
mysite.urls
image.png
👇
food.urls
image.png
👇
views.py
image.png

終わりましたよ

関連記事
・【Django】Build web apps ~1章:プロジェクト作成~
・【Django】Build web apps ~3章:Modelsとデータベース~

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?