3 ms·
Could you elaborate on that? I've used both and the difference (apart from the naming) is too subtle for me (not trolling - honest question).
by recurser 17y ago
Could you elaborate on that? I've used both and the difference (apart from the naming) is too subtle for me (not trolling - honest question).
- bdr 17y agohttp://docs.djangoproject.com/en/dev/faq/general/#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 http://docs.djangoproject.com/en/dev/faq/general/#django-app...
- olifante 17y agoThat's a specious distinction, even if I can understand their interpretation. It's just easier to say that: 1. Django Templates correspond to Rails Views (they both define how data is presented to the client). The biggest difference is that it's easier to include business logic in Rails Views because the Erb template language is as expressive as Ruby itself, while the Django template language is deliberately restrictive. 2. Django Views correspond to Rails Controllers (they both process requests). The biggest difference is that data is passed explicitely from a Django View to its Template, while data is passed implicitely from a Rails Controller to its View.
- adamt 17y agoIt'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#)