-
카테고리
-
세부 분야
풀스택
-
해결 여부
미해결
Internal 500 서버오류 질문드립니다
21.09.23 15:35 작성 조회수 179
0
TypeError: __init__() takes 1 positional argument but 2 were given 라는 오류가 자꾸뜹니다!
댓글작성만 누르면 이러네요 도와주세요 ㅠ
답변을 작성해보세요.
0
SHINH KIM
2023.01.10
댓글 전송이 안됩니다
왜 그런지 어느정도 짐작은 되는데 dj는 첨이라 해결방법을 모르겠어요.
도와주세요
axios 코드
onSubmitForm() {
let form = new FormData();
form.set("post", this.post?.id);
form.set("content", this.commentValue);
axios
.post("/api/post/comment/add/", form, {
// headers: { "X-CSRFToken": "{{csrf_token}}" },
})
.then((res) => {
console.log(res.data);
});
},
...
path('post/comment/add/', views.ApiAddComment.as_view(), name='add_comment'),
class ApiAddComment(BaseCreateView):
model = Comment
fields = '__all__'
def form_valid(self, form):
self.object = form.save()
comment = obj_to_comment(self.object)
return JsonResponse(data=comment, safe=True, status=201)
def form_invalid(self, form):
return JsonResponse(data=form.errors, safe=True, status=400)
error
@csrf_exempt
decorator 를 간단하게 붙혀 시도 해봤는데, as_view() 가 없다고 해서 이건 포기했는데
도와주세요
답변 3