OverIQ.com

Intro to Django

Last updated on July 27, 2020


Intro to Django #

When it comes to creating a web application using Python, Django is a big name. Django framework was created by Adrian Holovaty and Simon Willison while working in Lawrence Journal-World newspaper in 2003. They kept developing the framework for the next 2 years. In 2005, they decided to release the framework as open source software and named it Django. Fast forward to 2018, Django is still one of the most popular Python web framework.

What is a Web Framework #

A web framework is simply a software package which eases the process of creating web applications. If you have built websites from scratch then you would probably know that most web applications have a common set of functionality (like CRUD, form validation, authentication, sessions etc ).

Creating a web application without any framework means that you would have to re-write all this functionality every time you work on a new site.

A much better way would be to package your reusable code into separate libraries and then use it across all your projects. If you go with the latter option, you have effectively created a personal web framework.

A web framework is just that - a collection of libraries which are designed to work together. A library can do simple things as formatting time to complex as creating a full-fledged admin interface. A web framework allows us to get things done without re-writing same code over and over again.

Why use Django #

Here are some of the reasons to use Django:

  • BSD License - Django uses BSD License, which means you can modify and use it any way you want without any restrictions.

  • Fast Development - Developing web application in Django takes less time because the framework handles all the tedious aspect of web development. Django even comes with a complete admin site which you can use to manage the content of your web application.

  • Don't Repeat Yourself (DRY) - It is a principle in software development which means don't write the same thing again and again. Django adheres to the DRY principle, as a result, every knowledge within the framework must be placed in a single place.

  • Flexible - Django is highly flexible. Once you know the basics, you can easily customize the framework to suit your specific needs.

  • Great Community - Django is a mature framework with an excellent community. Consequently, you will find a lot of great third party packages with awesome documentation. Having an active community also means that bugs and issues will be resolved quickly.

  • Scalability - Django is scalable. Some of the biggest names on the Internet use Django. For example:

    • Instagram
    • BitBucket
    • Mozilla
    • NASA
    • Disqus
    • Onion
  • Enhanced Security - Securing a web application can be a daunting task even for an experienced developer. Django, being a good framework, handles all common security concerns like SQL injection, CSRF (Cross Site Request Forgery) and so on.

Prerequisite #

To go through this tutorial comfortably you should have a basic understanding of Python. If your Python is little hazy then this python tutorial would be a great read.

Before you begin #

This is a step by step tutorial to Django 1.11. To get the most out of this tutorial read chapters sequentially because each chapter builds upon the previous one.

All the examples in this tutorial are tested on Python 3.5. Although, Django 1.11 can also be used with Python 2.7, 3.4 and 3.6. You are free to follow along using any aforementioned versions of Python. However, I won't recommend using Python 2 because it is going to retire soon.