SHINH KIM
@shinh
Reviews Written
-
Average Rating
-
Posts
Q&A
Internal 500 ์๋ฒ์ค๋ฅ ์ง๋ฌธ๋๋ฆฝ๋๋ค
๋๊ธ ์ ์ก์ด ์๋ฉ๋๋ค ์ ๊ทธ๋ฐ์ง ์ด๋์ ๋ ์ง์์ ๋๋๋ฐ 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() ๊ฐ ์๋ค๊ณ ํด์ ์ด๊ฑด ํฌ๊ธฐํ๋๋ฐ ๋์์ฃผ์ธ์
- 0
- 3
- 294
Q&A
nodemon ์คํ
back์ชฝ package.json ์์ "script"์ "dev": "nodemon app.js", ์ด๊ฑฐ ์ถ๊ฐํ๊ฑฐ๋ ์์ ํด์ฃผ๊ณ ํฐ๋ฏธ๋์์ yarn devํ๋ฉด ์คํ๋ฉ๋๋ค.
- 0
- 2
- 646




