Django/Django Trouble Shooting
RuntimeError: You called this URL via PUT, but the URL doesn't end in a slash and you have APPEND_SLASH set.
veryhi
2023. 1. 30. 07:10
[전문]
RuntimeError: 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/content/2/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
[이유]
Django의 URL 정책에 의해서 발생하는 에러이다.
[해결]
urls.py 파일에 정의된 url 정책 중 /로 끝나는 것과 끝나지 않는 것 두가지 모두를 정의해주면 된다.
[예시]
path('content/<int:pk>/', views.ContentDetail.as_view()),
위의 상황에서,
path('content/<int:pk>/', views.ContentDetail.as_view()),
path('content/<int:pk>', views.ContentDetail.as_view()),
위와 같이 추가