Web Notes LogoWeb NotesHome

Introduction to Django

Author: Jina

Django is a Python web framework that helps developers build websites and web applications quickly, and efficiently. It has a lot of powerful built-in features, which eliminates the need for developers to code funcctions from scratch. In essence, Django helps you focus on building applications while handling the common web development tasks for you.

Official Django Website Tutorial

This official Django website has a very thorough tutorial that I HIGHLY recommend you follow. The following is just a preview you can read to better understand the concepts being introduced on their tutorial.

Analogy - Corporate Office (Site Level) and Individual Business (App Level)

To explain the basics of Django, I will use an analogy to breakdown the relationships between the different Django components.

Django Corporate Analogy

Framework for Django Corporate Analogy

Django Analogy Framework

Now that you're familiar with the analogy framework, let's do an example walk through.

Imaging you got an internship at Meta. Congratulations! It’s your dream internship and you’re super excited. However, it’s your first day and you’re someone who likes to visualize what the day is going to look like. So, you run the steps through your head.

  1. As an intern, you follow the address to a huge corporate building. As you enter the office, you enter the lobby and are met with a friendly front desk person. Similar to this, when navigating to a certain URL, you navigate to a site (corporate building) and end up on the landing page (lobby). In the backend, you are met with the URL configuration for the site (front desk person).
  2. You specify to the front desk person that you are looking to get to the Meta floor. The front desk person informs you that Meta will be on the 8th floor, however, from there another front desk person will help you navigate on the floor. Similar to this, when you specify a specific URL endpoint, the site-level URL configuration (front desk) will direct you to the specific app you’re looking for (Meta's floor), but will then pass on the responsibility of helping you as the client to the app-level URL configuration (Meta's front desk). This is done via theinclude() function, which tells Django to look inside this URL configuration to look for the rest of the URL endpoints.
  3. Django Include Function
  4. Once you make it to the Meta floor, you enter Meta’s lobby. You are met with another friendly front desk person for Meta, who asks where you need to go so they can help direct you. Similar to this, when you navigate to the app (Meta’s floor), you land on the index pagefor this application (Meta’s lobby), where you meet an app-level URL configuration (Meta’s front desk person) who is now responsible for helping you navigate the application.

Now that you have a general understanding of the Django framework and the relationship between Projects vs Apps, it's now time to go through the Django tutorial on their official website.