4 ms·
It's a subtle but important difference. Rather than MVC (Models, View, Controller), Django uses MTV - Models, Templates and Views. The M in both is pretty sim
by adamt 17y ago
It's a subtle but important difference.
Rather than MVC (Models, View, Controller), Django uses MTV - Models, Templates and Views.
The M in both is pretty similar, and is typically an object representation of what is in the database.
Django differs from the more established MVC model. In Django-speak a view is a function that takes optional arguments, processes data on the model, and (typically) outsets key/value pairs of object. They key/value pairs get fed into the template. E.g. if you did had a URL /sales/by_country, then a view would be executed that would do a query that returned the sales by country in a pure python data-type (e.g. a list). All the presentation code, would be be done in a template.
In MVC, you have controllers that were the 'business logic' and views that were the 'presentation code'.
MVC is arguably more pure from a design perspective, MTV arguably fits more naturally with the way the web works.
This 'snakes and rubies' video starring DHH and the Django team is a good session that explores it in more detail. (http://video.google.com/videoplay?docid=2939556954580527226# http://video.google.com/videoplay?docid=2939556954580527226#)