Showing posts with label views. Show all posts
Showing posts with label views. Show all posts

Thursday, 8 March 2012

Models, Views, Controllers

The other view of this holly triple is the Django's Models, Templates and Views.

It depends on the way you're looking at them

1) If you're looking from the perspective of a user, then the correct way it would seem to be the MVC!
* The user sees a View in the form of a widget, and he/she knows that when he clicks...
* He/She would see a controller (either a message or something else)
* In the end He/She would simply see the model as He/She would see the error messages or would use another tool to check up on the database
Simple as that...

2) The programmers way though is from the inside. (from the perspective of the application)
* The model:
Again this is our first priority. The model usually comes first.
* The view:
Remember! This thingy is connecting an URL portion with a piece of code that would handle the url and would do all the necessary actions in order to produce some widgets for the poor user to play with. Therefore this would be Controller in the 1) scheme.
* The template:
As we are programmers, the main thing we do is to translate one language into another. In our case we take something as Python but with ending tags and translate it into language the web can understand as html + widgets
The main _clue_ is that the templating language IS with ending tags (may be because it is a bit easier to parse? may be...)

! The python interpreter makes pretty amazing things (decisions) with indentation and that is our next clue....
See you next time imaginary readers! Ta-Ta!