Written by
django-style
on
on
Python) Django URLConf 설정
Python) Django URLConf 설정
반응형
Django URLConf 설정
참고: 생활코딩 Python Django Framework 강의 https://youtu.be/AafeZ6dxMzo
라우팅 순서 (URLConf 설정)
1. Project - urls.py > urlpattern에 path 참고
* path ( "URL 경로", "App urls 지정" )
path('', include('myApp.urls'))
2. App - urls.py > urlpattern에 path 참고
* path ( "URL 경로", "Views 함수명" )
path('', views.index)
3. App- views.py에 페이지 정의
from django.shortcuts import render, HttpResponse # Create your views here. def index(request): return HttpResponse("Welcome!")
가변 URL 처리 방법
App URL 예시 - /read/숫자
1. App - urls.py
path('read//', views.read)
2. App -views.py
def read(request, id): # id 파라미터로 인입 return HttpResponse("Read !!! " + id)
3. 출력된 뷰 페이지
반응형
from http://lopicit.tistory.com/512 by ccl(A) rewrite - 2022-01-01 03:01:38