HTTP
HTTP request methods
데이터에 대해 수행을 원하는 작업(행동)을 나타내는 것
→ 서버에게 원하는 작업의 종류를 알려주는 역할
대표적인 메서드
GET
: 리소스 조회
POST
: 데이터 생성/전송
http://127.0.0.1:8000/articles/create/?title=제목&content=내용Create 로직 수정 - http method POST로 변경
new.html의 form 요청은 새로운 article(새로운 데이터)를 생성하는 요청이기 때문에 앞의 실습에 사용한 GET 방법 보다는 POST method로 서버에 전달되는 것이 적절함!<!-- templates/articles/new.html -->
<form action="{% url 'articles:create' %}" method="POST">
<div>
<label for="title">Title: </label>
<input type="text" name="title" id="title">
</div>
<div>
<label for="content">Content: </label>
<textarea name="content" id="content"></textarea>
</div>
<input type="submit">
</form>
# articles/views.py
def create(request):
title = request.POST.get('title')
content = request.POST.get('content')
⇒ 이렇게 로직 수정하고 게시글 생성 테스트해보면 403 에러가 뜸 : “HTTP response status code”

figure 1
: 서버가 클라이언트의 요청에 대한 처리 결과를 나타내는 3자리 숫자임. 클라이언트는 이 코드를 통해 요청이 성공했는지, 실패했는지, 아니면 추가적인 조치가 필요한지 즉시 파악 가능함