Thursday, May 16, 2013

About Django MVC


Those three pieces together – data access logic, business logic, and presentation logic – comprise a concept that’s sometimes called the Model-View-Controller (MVC) pattern of software architecture.

Django fallows this MVC pattern and it can be called as MVC framework. Here’s roughly how the M, V, and C break down in Django:

Controller : 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. And Django reads a URL config file that tells it what to do with the incoming requests from browsers.

Model :  The model layer in Django means the database plus the Python code that directly uses it. It models reality. You capture whatever your website needs in database tables. Django helps you write Python classes (called models) that tie 1:1 to the database tables.

View : The view layer is the user interface. Django splits this up in the actual HTML pages and the Python code (called views) that renders them. And it also has an automatic web admin interface for editing the models



You also see MVT(Model, View , Template) explanation. There is a confusion b/w MVC view and python view and then you considered Django as MVT Framework J

M stands for “Model,” the data access layer.

T stands for “Template,” the presentation layer

V stands for “View,” the business logic layer.

3 comments: