10. MVT 란 - chohankyun/python-django-study GitHub Wiki
##Django appears to be a MVC framework, but you call the Controller the “view”, and the View the “template”. How come you don’t use the standard names?
Well, the standard names are debatable.
In our interpretation of MVC, the “view” describes the data that gets presented to the user. It’s not necessarily how the data looks, but which data is presented. The view describes which data you see, not how you see it. It’s a subtle distinction.
So, in our case, a “view” is the Python callback function for a particular URL, because that callback function describes which data is presented.
Furthermore, it’s sensible to separate content from presentation – which is where templates come in. In Django, a “view” describes which data is presented, but a view normally delegates to a template, which describes how the data is presented.
Where does the “controller” fit in, then? In Django’s case, it’s probably the framework itself: the machinery that sends a request to the appropriate view, according to the Django URL configuration.
If you’re hungry for acronyms, you might say that Django is a “MTV” framework – that is, “model”, “template”, and “view.” That breakdown makes much more sense.
At the end of the day, of course, it comes down to getting stuff done. And, regardless of how things are named, Django gets stuff done in a way that’s most logical to us.
장고 FAQ 에 나온 내용 입니다.
간단하게 정리 하면
- view 는 무슨 데이터를 보여 줄 것인가.
- template 는 데이터를 어떻게 보여 줄 것인가.
- 그럼 MVC 에서 말하는 C(controller) 는 어디냐? 아마도 장고 프레임워크 전체를 말하는거 아닐까?
URL 설정을 통해서 적당한 view 를 호출 하는 방법이 controller 가 아닌가? - 장고 스텝들이 가장 로직한 방법으로 MTV 라고 명했다.
그럼 model 은?
이부분은 제 생각을 적어 보겠습니다.
- 데이터 부분 이다.
- 객체에는 변수와 함수가 같이 있다,
그렇다면 model 안에 있는 변수를 처리하는 로직은 model 에 존재해야 하는게 맞는것 같다. - 그럼 model 에 존재하는 변수만을 처리해서 프로그램을 만들 수 있는가?
로직이 없으면 가능 할 수도 있다, 하지만 대부분은 여러 model 들 끼리 상호 작용을 하면서
로직을 전개 할 것이다. - 이렇게 두개 이상의 model 들의 상호 작용을 누가 담당 할 것인가?
제 생각에는 이부분도 View 부분에서 담당해야 한다고 생각합니다. - 위의 FAQ 에도 있지만 view 는 어떤 데이터를 보여 줄것인가 를 담당한다고 했기때문이다.
- 물론 다른 module 를 만들 수도 있다.(예, service, business, batch, etc..)
- 어쨌거나 장고에 의해서 만들어진 규칙을 가능 하면 지키면서 코딩하는 것이 조금 더
효율적으로 장고를 사용하는 방법인것 같다.