So what exactly is Django implementing?
Seems like there are
Models
Views
Templates
Models = Database mappings
Views = Grab relevant data from the models and formats it via templates
Templates = Display HTML depending on data given by Views
EDIT: S. Lott cleared a lot up with this in an edit to a previous post, but I would still like to hear other feedback. Thanks!
Is this correct? It really seems like Django is nowhere near the same as MVC and just confuses people by calling it that.
DJANGO MVC - MVT Pattern The Model-View-Template (MVT) is slightly different from MVC. In fact the main difference between the two patterns is that Django itself takes care of the Controller part (Software Code that controls the interactions between the Model and View), leaving us with the template.
Django appears to be a MVC framework, but you call the Controller the “view”, and the View the “template”.
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.
A controller is the heart of the system, it steers everything. For a web framework, this means handling requests and responses, setting up database connections and loading add-ons. For this, Django reads a settings file so that it knows what to load and set up.
Django's developers have a slightly non-traditional view on the MVC paradigm. They actually address this question in their FAQs, which you can read here. In their own words:
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With