ใ€Djangoใ€‘Build web apps~2์žฅ:Views์™€ URL Patterns~

3805 ๋‹จ์–ด macosPython3์žฅ๊ณ 

์žฅ๊ณ  ์›น ์•ฑ ๋งŒ๋“ค๊ธฐ



ใ€Djangoใ€‘Build web apps๏ฝž1์žฅ๏ผšํ”„๋กœ์ ํŠธ ์ž‘์„ฑ๏ฝž

๋น„์—ws. 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')),
]

์›€์ง์ž„ ์„ค๋ช…




๐Ÿ‘‡
ROOT_URLCONF
๐Ÿ‘‡
settings.py
๐Ÿ‘‡

๐Ÿ‘‡
mysite.urls

๐Ÿ‘‡
food.urls

๐Ÿ‘‡
views.py


๋๋‚ฌ์–ด.



๊ด€๋ จ ๊ธฐ์‚ฌ
ใƒปใ€Djangoใ€‘Build web apps๏ฝž1์žฅ๏ผšํ”„๋กœ์ ํŠธ ์ž‘์„ฑ๏ฝž
ใƒปใ€Djangoใ€‘Build web apps~3์žฅ:Models์™€ ๋ฐ์ดํƒ€๋ฒ ์ด์Šค~

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ