장고 인스톨 후

djano-admin (명령어 리스트 알려줌)

djano-admin startproject (프로젝트 경로)

djano-admin startapp (앱 경로,)

secrete key environ 설정 공식문서 참고

Quick Start - django-environ

경로 위임 방식

my project 의 url.py 에서 path의 패턴을 보고 include()함수로 위임할 앱 선택

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('admin/', admin.site.urls),
    path('account/', include('accountapp.urls')), // 앱의 라우팅 urls.py 생성해야함
]

acountapp.urls.py 내용 (view의 함수반환 + name 지정해줘야함)

from django.urls import path
from accountapp.views import hello_world

app_name = 'accountapp'

urlpatterns = [
    path('hello_world/', hello_world, name='hello_world'),

]

myapp url로 이동해서 위임할 views.py 의 함수 선택

from django.urls import path
from myapp import views

urlpatterns = [
    path('', views.index),
    path('careat/', views.create), 
    path('read/<id>/', views.read)
]

위와같이 /<>/ 꺽쇠안의 내용은 바뀔 수 있는 페이지.

그러므로 views 단의 함수의 인자에 id를 추가해주면 페이지의

def read(reuqest, id):
    global holos
    article = f''
    for holo in holos:
        if int(id) == int(holo["id"]):
            article = hololive_En(holo["idol"], holo["color"], holo["img"], holo["body"])
    return main_home(article)

views에 HttpResponse 모듈로 html 템플릿 반환