DEV Community

Cover image for Django - A Brief Introduction
Joseph Kariuki
Joseph Kariuki

Posted on

Django - A Brief Introduction

What is Django?

Image description
Django is a robust Python web framework that was named after one Jean Reinhardt, who was a Roman-French jazz, guitarist and music composer and Django was his nickname according to Wikipedia.
Most of us know "Django Unchained" as the Tarantino movie that was released in 2012 and featured Jamie Foxx however, I am here to disappoint you since this post isn't about that. It is about a rich Python web framework that once you dip your fingers in it, you'll highly likely want to dip your hands and feet in it. Let us briefly unbolt Django.
Django can also be referred to as an Model-View-Template (MVT) framework used to build web applications.

Who uses Django

Websites that use Django framework include (but not limited to) the following:

  1. Disqus This is a social website build on top of Django and other frameworks. It supports discussions, comments and audience activity analysis.
  2. Instagram A social network platform currently owned by Meta (previously FaceBook) that supports media uploading, social account management and handles huge traffic and enormous amounts of data thanks to Django.
  3. Spotify Music streaming and sharing platform that enables millions of subscribers around the world to listen, share and purchase music.
  4. Bitbucket Cloud-based Git repository that hosts millions of code repositories and supports developer communities
  5. Mozilla The code behind Mozilla website is based on Django project and serves very many diverse and independent pages with huge amounts of static and media content (images, JavaScript and Cascading Style Sheets).

Other Django powered websites include: Pinterest, Quora, The Onion and NASA Website

Why Django

Image description
Django framework is simple, yet sophisticated with a "batteries-included" approach which includes out-of-the box for mostly used functionalities such as the following:

  • Administrator user interface
  • Security and performance
  • Multiple database back end support
  • User authentication and by extension authorization
  • Rich REST API
  • Testing suite

I have recently deployed a simple Django website on Heroku that I developed from scratch demonstrating most of the above features. The live site resides at http://jkariukidev.herokuapp.com and the code base is on this repository. I have worked on a documentation to get you going by and it is still being improved.

There are many web frameworks out here but Django still remains that 'elephant in the room' when it comes to full-stack web development partly because of the rich features mentioned above and because; unlike micro-frameworks such as ExpressJS and Flask which yield more flexibility, Django surrenders flexibility and reduces opportunities for mistakes (and time spent in debugging the bugs associated with the mistakes) encountered in writing functionality code from scratch.

Django uses a Don't Repeat Yourself (DRY) principle which reduces code duplication.

Django includes a powerful Object Relational Mapper (ORM) layer by default that can be used to interact with various databases such as MySQL, SQLite, PostgreSQL and Oracle without having to rewrite the SQL dialect (language) code for each database back end since each database has its own dialect.

The Blues of Django

Image description
While Django is all good as a framework, there are some cons that come with it just like any other framework.

  1. Django can be a bloated framework for small projects. It may not be the best approach for small projects like one page websites and the like. Preferable for projects such as blogs, social websites and e-commerce sites.
  2. Monolithic architecture that limits developer's freedom in introducing new implementations outside Django. A workaround to this would include adding third-party packages into a Django project.
  3. Full knowledge of the framework may be required to kick-start on projects and may take time to learn the whole framework.

References

Interested in learning Django? Here are some reference links to posts and some reads on the ever growing web development framework.

Top comments (0)