본문 바로가기
개발일지/Django

Django - API REST JSON PUT RuntimeError

by 개발에정착하고싶다 2022. 10. 23.
RuntimeError at /todo/2
You called this URL via PUT, but the URL doesn't end in a slash and you have 
APPEND_SLASH set. Django can't redirect to the slash URL while maintaining PUT data. 
Change your form to point to 127.0.0.1:8000/todo/2/ (note the trailing slash), 
or set APPEND_SLASH=False in your Django settings.

이런 에러가 떴다.

이건 내가 JSON으로 PUT 해주고 싶은 내용이였는데 말이다.

 

내가 코드를 잘못 입력했나. 라는 생각과 함께

에러 메세지를 읽어봤다.

 

URL doesn't end in a slash

이 메세지를 보고

'응? JSON은 칼같이 주소를 /처리해줘야하는건가?

싶어서

마지막에 /까지 넣어서

127.0.0.1:8000/todo/2/

로했더니 정상적으로 작동했다.