인프런 커뮤니티 질문&답변
csrf token 문제가 해결이 안되요
작성
·
367
0
딜리트뷰에 데코레이터로 csrf_exempt를 적용했는데 에러가 발생합니다. 이유가무엇일까요?
from django.http import JsonResponse
from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import ListView, DeleteView
from todo.models import Todo
from django.http import JsonResponse
from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import ListView, DeleteView
from todo.models import Todo
@method_decorator(csrf_exempt, name='dispatch')
class ApiTodoDelV(DeleteView):
model = Todo
def delete(self, request, *args, **kwargs):
print("todo 삭제 실행 ~!")
self.object = self.get_object()
self.object.delete()
return JsonResponse(DATA={}, status=204)
error:
spread.js:25 DELETE http://127.0.0.1:8000/api/todo/1/delete/ 403 (Forbidden)
github:
https://github.com/hyunsokstar/vueDjTodo
답변 1
0
독자님.
api/urls.py 파일에서, views.ApiTodoDelV.as_view 부분에 ( ) 괄호가 누락되었습니다.
수정하면 잘 될 것입니다. 열공 하세요.





