Django

Code

Changeset 2825

Show
Ignore:
Timestamp:
05/03/06 16:21:25 (2 years ago)
Author:
adrian
Message:

Changed docs/faq.txt MVC question to use clearer argument made in Jacob's Google presentation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/faq.txt

    r2809 r2825  
    126126----------------------------------------------------------------------------------------------------------------------------------------------------- 
    127127 
    128 That's because Django isn't strictly a MVC framework. If you squint the right 
    129 way, you can call Django's database layer the "Model", the view functions the 
    130 "View", and the URL dispatcher the "Controller" -- but not really. 
    131  
    132 In fact, you might say that Django is a "MTV" framework -- that is, Model, 
    133 Template, and View make much more sense to us. 
    134  
    135 So, although we've been strongly influenced by MVC -- especially in the 
    136 separation-of-data-from-logic department -- we've also strayed from the path 
    137 where it makes sense. 
     128Well, the standard names are debatable. 
     129 
     130In our interpretation of MVC, the "view" describes the data that gets presented 
     131to the user. It's not necessarily *how* the data *looks*, but *which* data is 
     132presented. The view describes *which data you see*, not *how you see it.* It's 
     133a subtle distinction. 
     134 
     135So, in our case, a "view" is the Python callback function for a particular URL, 
     136because that callback function describes which data is presented. 
     137 
     138Furthermore, it's sensible to separate content from presentation -- which is 
     139where templates come in. In Django, a "view" describes which data is presented, 
     140but a view normally delegates to a template, which describes *how* the data is 
     141presented. 
     142 
     143Where does the "controller" fit in, then? In Django's case, it's probably the 
     144framework itself: the machinery that sends a request to the appropriate view, 
     145according to the Django URL configuration. 
     146 
     147If you're hungry for acronyms, you might say that Django is a "MTV" framework 
     148-- that is, "model", "template", and "view." That breakdown makes much more 
     149sense. 
     150 
     151At the end of the day, of course, it comes down to getting stuff done. And, 
     152regardless of how things are named, Django gets stuff done in a way that's most 
     153logical to us. 
    138154 
    139155<Framework X> does <feature Y> -- why doesn't Django?