Introduction to Django

Django is a web framework written in Paython. It’s free and open source web framework, used for rapid development. The Django project website defines Django as

“Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.”

Before start exploring about the Django, lets get an idea of what is web framework. Because most of the people compare Django with WordPress or tools like WordPress. Which is not correct?

Web framework is a package of software which provides code libraries to the developer to develop and design, scale-able, reliable, secure and maintainable dynamic websites, web applications and web services.

Web frameworks makes the developer life easy. Most of the sites have common functionality like URL routing, handling session, data validation, database manipulation, caching and security, and web frameworks prevents you from rewriting these functionalities. Not all the frameworks provide you these functionalities or some provide more then the one I listed. Most of the web frameworks follow the MVC (Model-View-Controller) architectural patterns. MVC architectural pattern, separate the data model with business rules from the user interface. Django, Ruby on Rails, Spring MVC, Stripes are the examples of web frameworks based on MVC pattern. Now the question is, is web frameworks are really required to develop web applications?  My answer will be that if you are a beginner level programmer who just start learning web development should not start with web frameworks. You should first get some idea about HTTP request, sessions, cookies, HTML, JavaScript and CSS. Whereas if you are an experienced programmer then I suggest you can use web frameworks which requires you to understand MVC, ORM (Object relational mapping), AJAX, scaffolding and security.

There are number of web frameworks available in Python. Web frameworks are divided into two types high level frameworks and micro frameworks.

High level frameworks

High level web frameworks are the ones which are used by perfectionists and used to maintain and develop large scale applications. Few examples are,

  • Django
  • Turbo Gears
  • web2py

Micro level frameworks

Micro level frameworks are the ones which are having minimal functionality of web frameworks.  Microframeworks lacks most of the functionality available in high end frameworks. These frameworks are handle to develop small scale websites. Few examples of microframeworks available in python language are,

  • Bottle
  • CherryPy
  • Flask
  • Pyramid

If you want to know in detail the complete list of web frameworks available for Python, please visit wiki python. This page provides good information about the frameworks and a brief introduction of each framework as well.

Django, the web framework for perfectionists with deadlines. Django is free open source high level Python web framework that aims fast and rapid development of web applications. Django follows the MVC (Model-View-Controller) pattern architecture, emphasizes on plug-able and reusable components and the principle of DRY (Don’t Repeat Yourself). Django is maintained by Django Software Foundation. Django contains ORM (Object Relational Mapper) which bridges between data models and relational database, a web template system for processing HTTP request and regular-expression-based URL dispatcher. Django core framework provide following builtin components,

  1. ORM, defines data models in Python, which includes dynamic database APIs.
  2. URL, define clean URLs by using regular expression. I will discuss URL and views in detail in later posts.
  3. Template contains the static HTML output part and special syntax for displaying dynamic content on the page.
  4. Forms, a powerful library included in the framework which handles data validation, HTML rendering of form and converting HTML input values into Python types.
  5. Authentication library includes user accounts, groups, permission and cookie based user session.
  6. Admin interface is a powerful feature of Django. It automatically reads the meta data from model class and provides interface to add/update contents.
  7. Internationalization library support multi-lingual and localization of date & time, numbers and time zones.
  8. Security component provides protection against Cross-site scripting, SQL injection, Cross Site Request Forgery (CSRF) and Remote code execution.

I will explain in depth each of the above mentioned components in detail in my upcoming posts. Some of the well known sites that uses Django are Pinterest, Instagram, NASAMozilla, The Washington Times, National GeographicDisqus, the Public Broadcasting ServiceBitbucket.

In the next post we will try our first Hello World program using Python tools for Visual Studio.

 

Posted in Django Tagged with: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*