-
django as.view() 그리고 dispatch()Python/초간단 장고 Django 2022. 9. 7. 23:59반응형
https://docs.djangoproject.com/en/4.1/ref/class-based-views/base/
클래스 뷰의 작동은 위 링크에 잘 설명되어 있습니다.
urls.py에 등록된 view class는 아래와 같이 작동합니다.
response = MyView.as_view()(request)
as.view()가 진입점이 되죠.
진입 후에는 다음 과정을 거칩니다.
Method Flowchart
setup()
dispatch()
http_method_not_allowed()
options()dispatch(request, *args, **kwargs)
The default implementation will inspect the HTTP method and attempt to delegate to a method that matches the HTTP method; a GET will be delegated to get(), a POST to post(), and so on.
dispatch()는 HTTP method를 검사하고,
HTTP method와 일치하는 메소드에 위임을 시도합니다.GET 요청이 들어오면 클래스 안에 get() 메소드를 실행하고,
POST가 들어오면, post() 메소드를 실행합니다.반응형