WEB/Django prac
[Django prac][ORM with View] CRUD 구현 2
bay07
2024. 3. 27. 15:42
1. articles > urls.py
더보기
from django.urls import path
from . import views
app_name = 'articles'
urlpatterns = [
# ''는 메인페이지를 의미한다.
path('', views.index, name='index'),
]
2. articles > views.py
더보기
from django.shortcuts import render
def index(request):
return render(request, 'articles/index.html')
3. articles > templates > articles > index.html
더보기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Articles</h1>
<hr>
</body>
</html>
4. 잘 출력되는지 확인하기
python manage.py runserver
http://127.0.0.1:8000/articles/