Can somebody explain me where the diferences are between Django and the Model View Controller pattern?
Functionally, what can we expect from those differences — i.e. what works differently comparing Django to, for example, Ruby on Rails?
Can somebody explain me where the diferences are between Django and the Model View Controller pattern?
Functionally, what can we expect from those differences — i.e. what works differently comparing Django to, for example, Ruby on Rails?
The Django FAQ itself is a decent place to start:
Bear in mind that “Model View Controller” is just a pattern, i.e. an attempt to describe a common architecture. So a better question might be “How well does Django fit the Model View Controller pattern?”
According to the Django Book, Django follows the MVC pattern closely enough to be called an MVC framework.
Django has been referred to as an MTV framework because the controller is handled by the framework itself and most of the excitement happens in models, templates and views.
You can read more about MTV / MVC here:
The MTV (or MVC) Development Pattern
When you code, not thinking about names of framework pieces, there are no susbtantive differences betw, for example RoR. But it depends on the use you give
models
, since on Django they easily contain some logic that on other frameworks would stay at controller level.The
view
on Django tends to be a set of queries for fetching data, and pass them to the template.In mvt, a request to a URL is dispatched to a View. This View calls into the Model, performs manipulations and prepares data for output. The data is passed to a Template that is rendered an emitted as a response. ideally in web frameworks, the controller is hidden from view.
This is where the difference is from MVC: in mvc, the user interacts with the gui, the controller handles the request and notifies the model and the view queries the model to display the result to the user.