장고 01 : html 연결

 1. 디렉토리 구조


pjt01(프로젝트), app01(앱)

2. web01\pjt01\app01\views.py

from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
def other(request):
    return render(request, 'test/index2.html')

여기서 test 하위 폴더에 index2.html이 있음


3. web01\pjt01\pjt01\urls.py

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


urlpatterns = [
    path('admin/', admin.site.urls),
    path('app01/', include('app01.urls2')),
]

여기서 app01/의 경로가 있는 경우 127.0.0.1:8000\app01/ 을 부라우져에 입력하면
실행이 됨


4. web01\pjt01\app01\urls2.py

from django.contrib import admin
from django.urls import path
from app01 import views
# from django.conf.urls import include

urlpatterns = [
    # localhost:8000/app01/
    path('', views.other, name='other'),

]

위에 from app01 import views가 있어야 함



댓글

이 블로그의 인기 게시물

abaqus gpu 사용

Chat GPI 활용