[Django 11] URL app별로 관리하기
장고 url이 제공하는 include() 함수를 사용하면, 프로젝트의 urls.py를 기능별로(app별로) 편하게 관리할 수 있다.
#project/urls.py
from django.urls import path
import hello.views
urlpatterns = [
path('admin/', admin.site.urls, name='admin'),
path('', hello.views.home, name='home'),
path('new/', hello.views.new, name='new'),
path('create/', hello.views.create, name='create'),
path('detail/<int:post_id>', hello.views.detail, name="detail"),
path('edit/<int:post_id>', hello.views.edit, name="edit"),
path('update/<int:post_id>', hello.views.update, name="update"),
path('delete/<int:post_id>',hello.views.delete,name="delete"),
]1. app 폴더 안에 urls.py 파일 생성
2. project 폴더의 url path() 수정
Last updated