Tuesday 12 February 2013

DJANGO





Django is a high level python web framework. First of all, why we need a framework?

Because frameworks intended to solve these problems:

1.  When multiple parts of our application needs to connect to the database.
2.  When the developer needs to worry about printing the "Content Type" line and remembering to close a 
     database connections.
3. When this code is reused in multiple environments with a 
     separate database.
4. When novice wishes to redesign the page.

MVC Design Pattern

In Django we split python code to over four Python files 
*Models.py 
*Views.py  
*Urls.py 
*HTML Template


1. Models : The file model.py contains the database description 
                   and is represented as Python class. This class is called Model. 
                   Using models we can create, retrieve, update and delete  the
                   records in our database. This makes it simple compared to 
                   SQL statements.

2. Views : The views.py file contains the business logic for the page.

3. Urls : The Urls.py file directs to the views corresponding to their 
              URL patterns.

4. HTML : The HTML templates gives designs to the web pages. 

These sections follows a pattern called Model-View-Controller (MVC).
Here database data (the model) is separate from request-routing logic (the controller), which in turn is separate from the user interface.

Advantage of this Model-View-Controller approach is that, the components are loosely coupled:

* Developer can change the URL for a part of the application without 
   affecting its implementation.
* Designers can change a page’s design in HTML code without modifying 
   Python code.
* Simple to rename a database table,since we need to specify the change in 
   a single place.

Here is the code simple paint application that i made using Django:

And here you will get the paint application that i developed in django and deployed in heroku free web server:



[Expecting Your Valuable Comments]
Thank You